Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-8382

ScheduleManager's skip repeats can be negative

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 6.0.0.CR1
    • JBossAS-4.2.3.GA, JBossAS-5.1.0.GA, 6.0.0.M4
    • Scheduling/Timers
    • None

      If you use org.jboss.varia.scheduler.ScheduleManager with short 'period' (say, '1' ms), result of skip repeats calculation can be negative and it causes wrong repetition.
      The cause is casting long to int.

      public void start() throws JMException
      {
      Date lStartDate = null;
      // Check if initial start date is in the past
      if (mStartDate.getTime() < new Date().getTime() && mPeriod > 0)
      {
      // If then first check if a repetition is in the future
      long lNow = new Date().getTime() + 100;
      int lSkipRepeats = (int) ((lNow - mStartDate.getTime()) / mPeriod) + 1;
      log.debug("Old start date: " + mStartDate + ", now: " + new Date(lNow) + ", Skip repeats: " + lSkipRepeats)

      BTW, org.jboss.varia.scheduler.Scheduler properly casts it to long.

              rhn-support-tkobayas Toshiya Kobayashi
              rhn-support-tkobayas Toshiya Kobayashi
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: