Fix AssertionError in ScheduledFutureTask (#10073)

Motivation:

Some JVMs (like OpenJDK 8 on Windows) use a low resolution timer in System.nanoTime() and may return the same value more than once. This triggered an assertion failure when deadlineNanos was equal to nanoTime and AbstractScheduledEventExecutor#pollScheduledTask called #setConsumed.

Modifications: 
With this change the assertion checks exactly the same condition as AbstractScheduledEventExecutor#pollScheduledTask, and will no longer fail under these circumstances.

Result:

Fixes #10070.
This commit is contained in:
djelinski 2020-03-03 14:34:51 +01:00 committed by GitHub
parent 7ab68adbe8
commit 1b0e3d95f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -109,7 +109,7 @@ final class ScheduledFutureTask<V> extends PromiseTask<V> implements ScheduledFu
// Optimization to avoid checking system clock again
// after deadline has passed and task has been dequeued
if (periodNanos == 0) {
assert nanoTime() > deadlineNanos;
assert nanoTime() >= deadlineNanos;
deadlineNanos = 0L;
}
}