From 9d262af01119fdf6d03bc6b985da1f927ecfe194 Mon Sep 17 00:00:00 2001 From: Thorsten Marx Date: Sun, 17 Nov 2024 20:05:21 +0100 Subject: [PATCH] fix execution --- .../core/scheduler/SingleCronJobRunner.java | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/cms-core/src/main/java/com/condation/cms/core/scheduler/SingleCronJobRunner.java b/cms-core/src/main/java/com/condation/cms/core/scheduler/SingleCronJobRunner.java index 7c664b7c..00c19fb2 100644 --- a/cms-core/src/main/java/com/condation/cms/core/scheduler/SingleCronJobRunner.java +++ b/cms-core/src/main/java/com/condation/cms/core/scheduler/SingleCronJobRunner.java @@ -22,12 +22,12 @@ * #L% */ - - import com.condation.cms.api.scheduler.CronJob; import com.condation.cms.api.scheduler.CronJobContext; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; + +import org.quartz.DisallowConcurrentExecution; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; @@ -36,25 +36,20 @@ * * @author t.marx */ +@DisallowConcurrentExecution public class SingleCronJobRunner implements Job { public static final String DATA_CRONJOB = "cronjob"; public static final String DATA_CONTEXT = "context"; - - private static final Lock lock = new ReentrantLock(true); - + @Override public void execute(JobExecutionContext context) throws JobExecutionException { - if (context.getJobDetail().getJobDataMap().get(DATA_CRONJOB) != null) { - CronJobContext jobContext = (CronJobContext) context.getJobDetail().getJobDataMap().get(DATA_CONTEXT); - - lock.lock(); - try { - ((CronJob)context.getJobDetail().getJobDataMap().get(DATA_CRONJOB)).accept(jobContext); - } finally { - lock.unlock(); - } + CronJobContext jobContext = (CronJobContext) context.getJobDetail().getJobDataMap().get(DATA_CONTEXT); + CronJob cronJob = (CronJob) context.getJobDetail().getJobDataMap().get(DATA_CRONJOB); + + if (cronJob != null && jobContext != null) { + cronJob.accept(jobContext); } } - + }