FIX: nextFuzzyTimestamp in past

This commit is contained in:
Patrick Haßel 2024-09-12 09:29:35 +02:00
parent 1c0ffc7b64
commit c174a18a4a

View File

@ -92,12 +92,14 @@ public class ScheduleEntry {
public void setNextClearTimestamp(final ZonedDateTime next) { public void setNextClearTimestamp(final ZonedDateTime next) {
nextClearTimestamp = next; nextClearTimestamp = next;
if (nextClearTimestamp == null) { nextFuzzyTimestamp = null;
nextFuzzyTimestamp = null; if (nextClearTimestamp != null) {
} else {
final int rangeFull = 2 * fuzzySeconds; final int rangeFull = 2 * fuzzySeconds;
final int fuzzySeconds = rangeFull > 0 ? RANDOM.nextInt(rangeFull) - this.fuzzySeconds : 0; final ZonedDateTime min = ZonedDateTime.now().plusMinutes(1);
nextFuzzyTimestamp = nextClearTimestamp.plusSeconds(fuzzySeconds); while (nextFuzzyTimestamp == null || nextFuzzyTimestamp.isBefore(min)) {
final int fuzzySeconds = rangeFull > 0 ? RANDOM.nextInt(rangeFull) - this.fuzzySeconds : 0;
nextFuzzyTimestamp = nextClearTimestamp.plusSeconds(fuzzySeconds);
}
} }
} }