File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
core/src/main/java/org/sterl/spring/persistent_tasks/scheduler/component Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -70,24 +70,27 @@ public Future<TriggerKey> submit(@Nullable TriggerEntity trigger) {
7070 if (trigger == null ) {
7171 return CompletableFuture .completedFuture (null );
7272 }
73-
73+ assertStarted ();
7474 try {
75- Future <TriggerKey > result ;
7675 synchronized (runningTasks ) {
77- if (stopped .get () || executor == null ) {
78- throw new IllegalStateException ("Executor of " + schedulerName + " is already stopped" );
79- }
80- result = executor .submit (() -> runTrigger (trigger ));
76+ assertStarted ();
77+ var result = executor .submit (() -> runTrigger (trigger ));
8178 runningTasks .put (trigger , result );
79+ return result ;
8280 }
83- return result ;
8481 } catch (Exception e ) {
8582 runningTasks .remove (trigger );
8683 throw new RuntimeException ("Failed to run " + trigger .getKey (), e );
8784 }
8885
8986 }
9087
88+ private void assertStarted () {
89+ if (stopped .get () || executor == null ) {
90+ throw new IllegalStateException ("Executor of " + schedulerName + " is already stopped" );
91+ }
92+ }
93+
9194 private TriggerKey runTrigger (TriggerEntity trigger ) {
9295 try {
9396 triggerService .run (trigger );
You can’t perform that action at this time.
0 commit comments