File tree Expand file tree Collapse file tree
src/main/java/com/coreoz/wisp Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -235,7 +235,8 @@ public CompletionStage<Job> cancel(String jobName) {
235235 Job job = findJob (jobName ).orElseThrow (IllegalArgumentException ::new );
236236
237237 synchronized (this ) {
238- if (job .status () == JobStatus .DONE ) {
238+ JobStatus jobStatus = job .status ();
239+ if (jobStatus == JobStatus .DONE ) {
239240 return CompletableFuture .completedFuture (job );
240241 }
241242 CompletableFuture <Job > existingHandle = cancelHandles .get (jobName );
@@ -244,15 +245,15 @@ public CompletionStage<Job> cancel(String jobName) {
244245 }
245246
246247 job .schedule (Schedule .willNeverBeExecuted );
247- if (job . status () == JobStatus .READY && threadPoolExecutor .remove (job .runningJob ())) {
248+ if (jobStatus == JobStatus .READY && threadPoolExecutor .remove (job .runningJob ())) {
248249 scheduleNextExecution (job );
249250 return CompletableFuture .completedFuture (job );
250251 }
251252
252- if (job . status () == JobStatus .RUNNING
253+ if (jobStatus == JobStatus .RUNNING
253254 // if the job status is/was READY but could not be removed from the thread pool,
254255 // then we have to wait for it to finish
255- || job . status () == JobStatus .READY ) {
256+ || jobStatus == JobStatus .READY ) {
256257 CompletableFuture <Job > promise = new CompletableFuture <>();
257258 cancelHandles .put (jobName , promise );
258259 return promise ;
You can’t perform that action at this time.
0 commit comments