FIX: Endless loop trying to find next Schedule execution

This commit is contained in:
Patrick Haßel 2021-10-28 20:47:46 +02:00
parent 009109c8f2
commit 86300531a9

View File

@ -61,7 +61,7 @@ public class ScheduleCalculationService {
ZonedDateTime midnight = now.withHour(0).withMinute(0).withSecond(0).withNano(0); ZonedDateTime midnight = now.withHour(0).withMinute(0).withSecond(0).withNano(0);
ZonedDateTime next = calculateEntryForDay(entry, midnight); ZonedDateTime next = calculateEntryForDay(entry, midnight);
while (next != null && (!next.isAfter(now) || !isAfterLast(entry, next) || !isWeekdayEnabled(entry, next))) { while (next != null && (!next.isAfter(now) || !isAfterLast(entry, next) || !isWeekdayEnabled(entry, next))) {
log.debug(" -- skipping: {}", next); log.debug(" -- skipping: next={}", next);
midnight = midnight.plusDays(1); midnight = midnight.plusDays(1);
next = calculateEntryForDay(entry, midnight); next = calculateEntryForDay(entry, midnight);
} }
@ -70,7 +70,7 @@ public class ScheduleCalculationService {
} }
private boolean isAfterLast(final ScheduleEntry entry, final ZonedDateTime next) { private boolean isAfterLast(final ScheduleEntry entry, final ZonedDateTime next) {
return entry.getLastClearTimestamp() == null || !next.isAfter(entry.getLastClearTimestamp()); return entry.getLastClearTimestamp() == null || next.isAfter(entry.getLastClearTimestamp());
} }
private ZonedDateTime calculateEntryForDay(final ScheduleEntry entry, final ZonedDateTime midnight) { private ZonedDateTime calculateEntryForDay(final ScheduleEntry entry, final ZonedDateTime midnight) {