Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2455

One-off and past CronSchedule jobs never get ended in PeriodicExecutor

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.4
    • 5.4
    • tapestry-ioc

    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) {
      

      .....

      Attachments

        Activity

          People

            jkemnade Jochen Kemnade
            mearing Mark Mearing-Smith
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: