From 3eec26b0a24e07601cb222a4d2b17442bd338fc2 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Thu, 3 Apr 2014 13:27:33 +0200 Subject: [PATCH] [#2358] SslHandler.safeClose(...) may not notify the ChannelPromise Motivation: In SslHandler.safeClose(...) we attach a ChannelFutureListener to the flushFuture and will notify the ChannelPromise which was used for close(...) in it. The problem here is that we only call ChannelHandlerContext.close(ChannelPromise) if Channel.isActive() is true and otherwise not notify it at all. We should just call ChannelHandlerContext.close(ChannelPromise) in all cases. Modifications: Always call ChannelHandlerContext.close(ChannelPromise) in the ChannelFutureListeiner Result: ChannelPromise used for close the Channel is notified in all cases --- handler/src/main/java/io/netty/handler/ssl/SslHandler.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/handler/src/main/java/io/netty/handler/ssl/SslHandler.java b/handler/src/main/java/io/netty/handler/ssl/SslHandler.java index 57b71be4b8..be4eff9ab1 100644 --- a/handler/src/main/java/io/netty/handler/ssl/SslHandler.java +++ b/handler/src/main/java/io/netty/handler/ssl/SslHandler.java @@ -1171,9 +1171,9 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH if (timeoutFuture != null) { timeoutFuture.cancel(false); } - if (ctx.channel().isActive()) { - ctx.close(promise); - } + // Trigger the close in all cases to make sure the promise is notified + // See https://github.com/netty/netty/issues/2358 + ctx.close(promise); } }); }