From 956c0f8b9059c84122357000258a00cf0bc5e905 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Tue, 2 Jul 2013 17:22:56 +0900 Subject: [PATCH] Better explanation of reentrance issue of ChannelOutboundBuffer --- .../main/java/io/netty/channel/ChannelOutboundBuffer.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java b/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java index 3da56e62cb..9185585515 100644 --- a/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java +++ b/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java @@ -214,13 +214,15 @@ final class ChannelOutboundBuffer { } void fail(Throwable cause) { - // We need to check if we already process the fail here as the notification of the future may trigger some - // other event which will also call ChannelOutboundBuffer and so set currentMessage and currentPromise to - // null. + // Make sure that this method does not reenter. A listener added to the current promise can be notified by the + // current thread in the tryFailure() call of the loop below, and the listener can trigger another fail() call + // indirectly (usually by closing the channel.) + // // See https://github.com/netty/netty/issues/1501 if (inFail) { return; } + try { inFail = true; if (currentPromise == null) {