diff --git a/core/src/main/java/hudson/model/AperiodicWork.java b/core/src/main/java/hudson/model/AperiodicWork.java index bccb84b8eaba69c384a102242f3352e0e9e1f0a9..b46ac8fc0e4782c28ce0df3c581906da66fe1d35 100644 --- a/core/src/main/java/hudson/model/AperiodicWork.java +++ b/core/src/main/java/hudson/model/AperiodicWork.java @@ -74,7 +74,11 @@ public abstract class AperiodicWork extends SafeTimerTask implements ExtensionPo * By default it chooses the value randomly between 0 and {@link #getRecurrencePeriod()} */ public long getInitialDelay() { - return Math.abs(RANDOM.nextLong())%getRecurrencePeriod(); + long l = RANDOM.nextLong(); + // Math.abs(Long.MIN_VALUE)==Long.MIN_VALUE! + if (l==Long.MIN_VALUE) + l++; + return Math.abs(l)%getRecurrencePeriod(); } @Override diff --git a/core/src/main/java/hudson/model/PeriodicWork.java b/core/src/main/java/hudson/model/PeriodicWork.java index 6faec3840b538e0b3557dc4aa48abf91e45a657d..9bb02abd3a4fb4a3f884a597ac6f3f7723929a2c 100644 --- a/core/src/main/java/hudson/model/PeriodicWork.java +++ b/core/src/main/java/hudson/model/PeriodicWork.java @@ -75,7 +75,11 @@ public abstract class PeriodicWork extends SafeTimerTask implements ExtensionPoi * By default it chooses the value randomly between 0 and {@link #getRecurrencePeriod()} */ public long getInitialDelay() { - return Math.abs(RANDOM.nextLong())%getRecurrencePeriod(); + long l = RANDOM.nextLong(); + // Math.abs(Long.MIN_VALUE)==Long.MIN_VALUE! + if (l==Long.MIN_VALUE) + l++; + return Math.abs(l)%getRecurrencePeriod(); } /**