[ https://issues.apache.org/jira/browse/TAP5-2455?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jochen Kemnade closed TAP5-2455. -------------------------------- Resolution: Fixed Fix Version/s: 5.4 Thanks, I had to tweak the patch a bit because it would have caused a {{ConcurrentModificationException}} when trying to remove a job from the job list while iterating over it. > One-off and past CronSchedule jobs never get ended in PeriodicExecutor > ---------------------------------------------------------------------- > > Key: TAP5-2455 > URL: https://issues.apache.org/jira/browse/TAP5-2455 > Project: Tapestry 5 > Issue Type: Bug > Components: tapestry-ioc > Affects Versions: 5.4 > Reporter: Mark Mearing-Smith > Assignee: Jochen Kemnade > Labels: patch > Fix For: 5.4 > > Attachments: > 0001-Fixed-PeriodicExecutorImpl-problem-when-next-executi.patch > > > If you add a job with a CronSchedule that is to be run at only one time to > the PeriodicExecutor, it will never stop executing. It also happens if you > add one in the past: > The code below will run indefinitely now even though the cron was scheduled > to run at midnight 1-Jan-2014: > {code} > periodicExecutor.addJob( > new CronSchedule("0 0 0 1 1 ? 2014"), "Test", > new Runnable() { > @Override > public void run() { > System.out.println("Testing the run"); > } > } > ); > {code} > The problem is CronSchedule.nextExecution() returns 0 if there is no valid > date in the future. This then leads PeriodicExecutorImpl to sleep for 0 > seconds between runs. > My suggestion is around line 370 to do something like: > {code} > if (jobNextExecution == 0) { > job.cancel(); > } else if (jobNextExecution <= now) { > {code} > ..... -- This message was sent by Atlassian JIRA (v6.3.4#6332)