Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Commit a58bbc5

Browse files
authored
Fix task-single NPE (#162)
1 parent 03ac1b9 commit a58bbc5

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,10 @@ public class ApplicationTest {}
755755

756756
## Release notes
757757

758+
### 1.6.1
759+
760+
* Fix a NPE on `task-single` command.
761+
758762
### 1.6.0
759763

760764
* Added the command [tasks-single](#tasks) to launch a single execution of a scheduled task

starter/src/main/java/com/github/fonimus/ssh/shell/commands/TasksCommand.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,27 @@
1616

1717
package com.github.fonimus.ssh.shell.commands;
1818

19-
import com.github.fonimus.ssh.shell.SimpleTable;
20-
import com.github.fonimus.ssh.shell.SshShellHelper;
21-
import com.github.fonimus.ssh.shell.SshShellProperties;
2219
import lombok.AllArgsConstructor;
2320
import lombok.Data;
2421
import lombok.NoArgsConstructor;
2522
import lombok.extern.slf4j.Slf4j;
23+
24+
import java.lang.reflect.Method;
25+
import java.time.Duration;
26+
import java.time.ZoneOffset;
27+
import java.time.format.DateTimeFormatter;
28+
import java.util.ArrayList;
29+
import java.util.Collection;
30+
import java.util.Date;
31+
import java.util.HashMap;
32+
import java.util.List;
33+
import java.util.Map;
34+
import java.util.Set;
35+
import java.util.UUID;
36+
import java.util.concurrent.Executors;
37+
import java.util.concurrent.ScheduledFuture;
38+
import java.util.stream.Collectors;
39+
2640
import org.springframework.beans.factory.DisposableBean;
2741
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
2842
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -50,15 +64,9 @@
5064
import org.springframework.shell.standard.ValueProviderSupport;
5165
import org.springframework.stereotype.Component;
5266

53-
import java.lang.reflect.Method;
54-
55-
import java.time.Duration;
56-
import java.time.ZoneOffset;
57-
import java.time.format.DateTimeFormatter;
58-
import java.util.*;
59-
import java.util.concurrent.Executors;
60-
import java.util.concurrent.ScheduledFuture;
61-
import java.util.stream.Collectors;
67+
import com.github.fonimus.ssh.shell.SimpleTable;
68+
import com.github.fonimus.ssh.shell.SshShellHelper;
69+
import com.github.fonimus.ssh.shell.SshShellProperties;
6270

6371
import static org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.DEFAULT_TASK_SCHEDULER_BEAN_NAME;
6472

@@ -323,7 +331,7 @@ public String tasksSingle(
323331
try {
324332
String executionId = taskName + "-" + generateExecutionId();
325333
// Will run the Runnable immediately or as soon as possible
326-
ScheduledFuture<?> future = taskScheduler.schedule(state.getScheduledTask().getTask().getRunnable(), new Date());
334+
ScheduledFuture<?> future = taskScheduler().schedule(state.getScheduledTask().getTask().getRunnable(), new Date());
327335
statesByName.put(executionId, new TaskState(executionId, null, TaskStatus.running, future));
328336
started.add(executionId);
329337
} catch (TaskRejectedException e) {

0 commit comments

Comments
 (0)