From 1b0e3d95f43b710261695b1731522ed3b6d29e0d Mon Sep 17 00:00:00 2001 From: djelinski <30433125+djelinski@users.noreply.github.com> Date: Tue, 3 Mar 2020 14:34:51 +0100 Subject: [PATCH] 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. --- .../main/java/io/netty/util/concurrent/ScheduledFutureTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/io/netty/util/concurrent/ScheduledFutureTask.java b/common/src/main/java/io/netty/util/concurrent/ScheduledFutureTask.java index 023c498f34..227894077a 100644 --- a/common/src/main/java/io/netty/util/concurrent/ScheduledFutureTask.java +++ b/common/src/main/java/io/netty/util/concurrent/ScheduledFutureTask.java @@ -109,7 +109,7 @@ final class ScheduledFutureTask extends PromiseTask 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; } }