[ 
https://issues.apache.org/jira/browse/TAP5-2455?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mark Mearing-Smith updated TAP5-2455:
-------------------------------------
    Description: 
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:

periodicExecutor.addJob(
    new CronSchedule("0 0 0 1 1 ? 2014"), "Test",
    new Runnable() {
        @Override
        public void run() {
            System.out.println("Testing the run");
        }
    }
);

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:
if (jobNextExecution == 0) {
    job.cancel();
} else if (jobNextExecution <= now) {
.....


  was:
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 it was scheduled to run at 
midnight 1-Jan-2014:

periodicExecutor.addJob(
    new CronSchedule("0 0 0 1 1 ? 2014"), "Test",
    new Runnable() {
        @Override
        public void run() {
            System.out.println("Testing the run");
        }
    }
);

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:
if (jobNextExecution == 0) {
    job.cancel();
} else if (jobNextExecution <= now) {
.....



> 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
>            Reporter: Mark Mearing-Smith
>
> 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:
> periodicExecutor.addJob(
>     new CronSchedule("0 0 0 1 1 ? 2014"), "Test",
>     new Runnable() {
>         @Override
>         public void run() {
>             System.out.println("Testing the run");
>         }
>     }
> );
> 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:
> if (jobNextExecution == 0) {
>     job.cancel();
> } else if (jobNextExecution <= now) {
> .....



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to