From 47f961b6b9a2541737d2407dcfc12ae010a8e9a1 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 23 May 2014 09:47:22 +0900 Subject: [PATCH] Fix a bug in DefaultPromise.notifyLateListener() where the listener is not notified Motivation: When (listeners == null && lateListeners == null) and (stackDepth >= MAX_LISTENER_STACK_DEPTH), the listener is not notified at all. The discard client does not work. Modification: Make sure to submit the notification task. Result: The discard client works again and all listeners are notified. --- .../io/netty/util/concurrent/DefaultPromise.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java b/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java index 00b105836b..c478627b32 100644 --- a/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java +++ b/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java @@ -624,6 +624,7 @@ public class DefaultPromise extends AbstractFuture implements Promise { } finally { LISTENER_STACK_DEPTH.set(stackDepth); } + return; } } else { LateListeners lateListeners = this.lateListeners; @@ -632,13 +633,14 @@ public class DefaultPromise extends AbstractFuture implements Promise { } lateListeners.add(l); execute(executor, lateListeners); + return; } - } else { - // Add the late listener to lateListeners in the executor thread for thread safety. - // We could just make LateListeners extend ConcurrentLinkedQueue, but it's an overkill considering - // that most asynchronous applications won't execute this code path. - execute(executor, new LateListenerNotifier(l)); } + + // Add the late listener to lateListeners in the executor thread for thread safety. + // We could just make LateListeners extend ConcurrentLinkedQueue, but it's an overkill considering + // that most asynchronous applications won't execute this code path. + execute(executor, new LateListenerNotifier(l)); } protected static void notifyListener(