From dbe886f7a0e74e17b1d7c4ed476226f00647cd12 Mon Sep 17 00:00:00 2001 From: fudongying Date: Mon, 3 Jul 2023 15:52:07 +0800 Subject: [PATCH] fix: deschedule failed after schedule exception --- .../opensearch/jobscheduler/scheduler/JobScheduler.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/opensearch/jobscheduler/scheduler/JobScheduler.java b/src/main/java/org/opensearch/jobscheduler/scheduler/JobScheduler.java index faf4f495..ad015f07 100644 --- a/src/main/java/org/opensearch/jobscheduler/scheduler/JobScheduler.java +++ b/src/main/java/org/opensearch/jobscheduler/scheduler/JobScheduler.java @@ -119,13 +119,10 @@ public boolean deschedule(String indexName, String id) { jobInfo.setExpectedPreviousExecutionTime(null); Scheduler.ScheduledCancellable scheduledCancellable = jobInfo.getScheduledCancellable(); - if (scheduledCancellable != null) { - if (scheduledCancellable.cancel()) { - this.scheduledJobInfo.removeJob(indexName, id); - } else { - return false; - } + if (scheduledCancellable != null && scheduledCancellable.cancel() == false) { + return false; } + this.scheduledJobInfo.removeJob(indexName, id); return true; }