RunTimeCalculator::nextRunTime ignores prevRunTime with CRON_EXPRESSION schedule type

Issue #12 resolved
Jon Hartlaub created an issue

Note in the following function prevRunTime is ignored for generating the next run time for CRON_EXPRESSION schedule type. This makes the function confusing and less useful.

public Date nextRunTime(final Schedule schedule, @Nullable final Date prevRunTime) throws CronSyntaxException {
    notNull("schedule", schedule);

    switch (schedule.getType()) {
        case INTERVAL:
            return nextRunTime(schedule.getIntervalScheduleInfo(), prevRunTime);
        case CRON_EXPRESSION:
            return nextRunTime(schedule.getCronScheduleInfo());
        default:
            throw new IllegalArgumentException("Unsupported schedule type: " + schedule.getType());
    }
}

Comments (2)

  1. Chris Fuller

    What's happened here is that originally this method was intended to mean next run time from now, and the only reason the prevRunTime is provided is that it might not exactly match "now". I agree that there's no real reason to explicitly disallow prevRunTime from meaning anything just some of the time.

  2. Log in to comment