提交 5a2a2b34 编写于 作者: C Christoph Kutzinski

Fixed FindBugs reported bug in initialDelay calculation - actually this would...

Fixed FindBugs reported bug in initialDelay calculation - actually this would probably only go wrong once in 10000 years or so, but better be safe ;)
上级 1592560d
......@@ -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
......
......@@ -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();
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册