Skip to content

Commit

Permalink
Fix a race condition when unscheduling jobs that trigger immediately
Browse files Browse the repository at this point in the history
This fixes an edge case where a scheduled job that triggers
immediately after it's scheduled can end up trying to unschedule
itself before it was added to the currentJobs map, resulting in a
partial unscheduling and subsequent calls to unschedule returning true
instead of false.
  • Loading branch information
bbrowning committed Apr 16, 2015
1 parent 50c6493 commit 3e507cf
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -220,7 +220,9 @@ public String getName() {
}
public void triggerComplete(Trigger trigger, JobExecutionContext ctx, Trigger.CompletedExecutionInstruction i) {
if (!trigger.mayFireAgain()) {
QuartzScheduling.this.currentJobs.remove(ctx.getJobDetail().getKey());
synchronized(QuartzScheduling.this) {
QuartzScheduling.this.currentJobs.remove(ctx.getJobDetail().getKey());
}
}
}
}
Expand Down

0 comments on commit 3e507cf

Please sign in to comment.