[ https://issues.apache.org/jira/browse/SLING-5666?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15290990#comment-15290990 ]
Damien Obrist commented on SLING-5666: -------------------------------------- [~cziegeler] Thanks! The fix works and looks good to me from what I can see. One thing I wonder about though is that {{ScheduledJobHandler#remove}} contains the following [code|https://github.com/apache/sling/blob/caba56abb49cb173cf6c9903a0facb2b6d31e56c/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/scheduling/ScheduledJobHandler.java#L480-L485]: {code} synchronized ( this.scheduledJobs ) { final Holder h = scheduledJobs.remove(scheduleKey); if ( h != null && h.info != null ) { jobScheduler.unscheduleJob(h.info); } } {code} This code should in theory already call {{JobSchedulerImpl#unscheduleJob}}, which you now call explicitly in your [updated fix|https://fisheye6.atlassian.com/changelog/sling?cs=1744360]. Except that this doesn't seem to happen, because the map {{ScheduledJobHandler.scheduledJobs}} doesn't contain the job yet - it is added there only asynchronously in {{ScheduledJobHandler#handleAddUpdate}}. Is that maybe something that should change? I don't grasp the complete code, so I can't really tell. > Unscheduling a job should remove corresponding node > --------------------------------------------------- > > Key: SLING-5666 > URL: https://issues.apache.org/jira/browse/SLING-5666 > Project: Sling > Issue Type: Bug > Components: Extensions > Affects Versions: Event 4.0.0, Event 4.0.2 > Reporter: Damien Obrist > Assignee: Carsten Ziegeler > Fix For: Event 4.1.0 > > > Unscheduling a previously scheduled job does not remove the corresponding > node below {{/var/eventing/scheduled-jobs}}: > {code:java} > ScheduledJobInfo info = > jobManager.createJob(topic).schedule().at(date).add(); > // creates /var/eventing/scheduled-jobs/c204a1ad-b161-4e76-9dfe-4152bca088cf > info.unschedule(); > // /var/eventing/scheduled-jobs/c204a1ad-b161-4e76-9dfe-4152bca088cf persists > {code} > This can lead to the situation where > [ScheduledJobHandler#scan|https://github.com/apache/sling/blob/caba56abb49cb173cf6c9903a0facb2b6d31e56c/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/scheduling/ScheduledJobHandler.java#L142-L174] > picks the node back up again and reschedules the job. > This is a regression introduced by SLING-4680. Before the changes of > SLING-4680, {{JobSchedulerImpl#unschedule}} took care of [removing the > node|https://github.com/apache/sling/blob/6eaa6a131b4013c5b4990ee126f6af1c5710d5de/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobSchedulerImpl.java#L335-L353]. > Currently, this is [not being done > anymore|https://github.com/apache/sling/blob/caba56abb49cb173cf6c9903a0facb2b6d31e56c/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/scheduling/JobSchedulerImpl.java#L196-L202]. -- This message was sent by Atlassian JIRA (v6.3.4#6332)