From a4d0341ea11140b1cfed2414f5292dffd3445dc8 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 19 Jul 2013 11:18:41 +0200 Subject: [PATCH] [#1614] Fix bug in SingleThreadEventExecutor which prevent scheduled tasks to get executed The problem was that with OioSocketChannel there was always a read Task in the taskQueue and with the old logic it never tried to execute scheduled tasks if there was at least one task in the taskQueue. --- .../netty/util/concurrent/SingleThreadEventExecutor.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/io/netty/util/concurrent/SingleThreadEventExecutor.java b/common/src/main/java/io/netty/util/concurrent/SingleThreadEventExecutor.java index c3e6e1963e..c6a1893aa9 100644 --- a/common/src/main/java/io/netty/util/concurrent/SingleThreadEventExecutor.java +++ b/common/src/main/java/io/netty/util/concurrent/SingleThreadEventExecutor.java @@ -213,18 +213,19 @@ public abstract class SingleThreadEventExecutor extends AbstractEventExecutor { return task; } else { long delayNanos = delayedTask.delayNanos(); - Runnable task; + Runnable task = null; if (delayNanos > 0) { try { task = taskQueue.poll(delayNanos, TimeUnit.NANOSECONDS); } catch (InterruptedException e) { return null; } - } else { - task = taskQueue.poll(); } - if (task == null) { + // We need to fetch the delayed tasks now as otherwise there may be a chance that + // delayed tasks are never executed if there is always one task in the taskQueue. + // This is for example true for the read task of OIO Transport + // See https://github.com/netty/netty/issues/1614 fetchFromDelayedQueue(); task = taskQueue.poll(); }