Better exception message when tickDuration is too big
- Related: #1246 - Fix misc inspector warnings
This commit is contained in:
parent
b58e6787ee
commit
e8ee6a2772
@ -197,11 +197,13 @@ public class HashedWheelTimer implements Timer {
|
||||
mask = wheel.length - 1;
|
||||
|
||||
// Convert tickDuration to nanos.
|
||||
this.tickDuration = tickDuration = unit.toNanos(tickDuration);
|
||||
this.tickDuration = unit.toNanos(tickDuration);
|
||||
|
||||
// Prevent overflow.
|
||||
if (tickDuration == Long.MAX_VALUE || tickDuration >= Long.MAX_VALUE / wheel.length) {
|
||||
throw new IllegalArgumentException("tickDuration is too long: " + tickDuration + ' ' + unit);
|
||||
if (this.tickDuration >= Long.MAX_VALUE / wheel.length) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"tickDuration: %d (expected: 0 < tickDuration in nanos < %d",
|
||||
tickDuration, Long.MAX_VALUE / wheel.length));
|
||||
}
|
||||
|
||||
workerThread = threadFactory.newThread(worker);
|
||||
@ -339,7 +341,7 @@ public class HashedWheelTimer implements Timer {
|
||||
if (workerState.get() == WORKER_STATE_SHUTDOWN) {
|
||||
throw new IllegalStateException("Cannot enqueue after shutdown");
|
||||
}
|
||||
final int stopIndex = (int) ((wheelCursor + relativeIndex) & mask);
|
||||
final int stopIndex = (int) (wheelCursor + relativeIndex & mask);
|
||||
timeout.stopIndex = stopIndex;
|
||||
timeout.remainingRounds = remainingRounds;
|
||||
wheel[stopIndex].add(timeout);
|
||||
@ -462,7 +464,7 @@ public class HashedWheelTimer implements Timer {
|
||||
//
|
||||
// See https://github.com/netty/netty/issues/356
|
||||
if (PlatformDependent.isWindows()) {
|
||||
sleepTimeMs = (sleepTimeMs / 10) * 10;
|
||||
sleepTimeMs = sleepTimeMs / 10 * 10;
|
||||
}
|
||||
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user