karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [karaf] branch karaf-4.2.x updated: [KARAF-6237] Fix reschedule action in the scheduler
Date Tue, 16 Apr 2019 06:52:53 GMT
This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch karaf-4.2.x
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/karaf-4.2.x by this push:
     new 8f18c8d  [KARAF-6237] Fix reschedule action in the scheduler
8f18c8d is described below

commit 8f18c8db85d1ee71a2b4f12df66c1cc29bc50195
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
AuthorDate: Mon Apr 15 15:32:07 2019 +0200

    [KARAF-6237] Fix reschedule action in the scheduler
---
 .../karaf/scheduler/core/QuartzScheduler.java      | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/scheduler/src/main/java/org/apache/karaf/scheduler/core/QuartzScheduler.java
b/scheduler/src/main/java/org/apache/karaf/scheduler/core/QuartzScheduler.java
index 0a743b6..b9eb680 100644
--- a/scheduler/src/main/java/org/apache/karaf/scheduler/core/QuartzScheduler.java
+++ b/scheduler/src/main/java/org/apache/karaf/scheduler/core/QuartzScheduler.java
@@ -54,7 +54,7 @@ public class QuartzScheduler implements Scheduler {
     static final String DATA_MAP_OPTIONS = "QuartzJobScheduler.Options";
 
     /** Map key for non serializable context. */
-    static final String DATA_MAP_CONTEXT = "QuarteJobScheduler.Context";
+    static final String DATA_MAP_CONTEXT = "QuartzJobScheduler.Context";
 
     /** Map key for the logger. */
     static final String DATA_MAP_LOGGER = "QuartzJobScheduler.Logger";
@@ -246,28 +246,30 @@ public class QuartzScheduler implements Scheduler {
     }
 
     @Override
-    public void reschedule(String name, ScheduleOptions options) throws SchedulerError {
+    public void reschedule(String jobName, ScheduleOptions options) throws SchedulerError
{
         final org.quartz.Scheduler s = this.scheduler;
-        if (name == null) {
+        if (jobName == null) {
             throw new IllegalArgumentException("Job name is mandatory");
         }
-        JobKey key = JobKey.jobKey(name);
+        JobKey key = JobKey.jobKey(jobName);
         if (key == null) {
-            throw new IllegalStateException("No job found with name " + name);
+            throw new IllegalStateException("No job found with name " + jobName);
         }
         try {
             JobDetail detail = s.getJobDetail(key);
 
-            Object job = detail.getJobDataMap().get(DATA_MAP_OBJECT);
+            final String contextKey = key.toString();
+            JobDataMap karafContext = ((KarafStdScheduler) s).getStorage().get(contextKey);
+            Object job = karafContext.get(QuartzScheduler.DATA_MAP_OBJECT);
 
             s.deleteJob(key);
 
             final InternalScheduleOptions opts = (InternalScheduleOptions)options;
-            Trigger trigger = opts.compile().withIdentity(name).build();
-            JobDataMap jobDataMap = this.initDataMap(name, job, opts);
-            detail = createJobDetail(name, jobDataMap, opts.canRunConcurrently);
+            Trigger trigger = opts.compile().withIdentity(jobName).build();
+            JobDataMap jobDataMap = this.initDataMap(jobName, job, opts);
+            detail = createJobDetail(jobName, jobDataMap, opts.canRunConcurrently);
 
-            logger.debug("Update job scheduling {} with name {} and trigger {}", job, name,
trigger);
+            logger.debug("Update job scheduling {} with name {} and trigger {}", job, jobName,
trigger);
             s.scheduleJob(detail, trigger);
         } catch (SchedulerException e) {
             throw new SchedulerError(e);


Mime
View raw message