diff --git a/src/main/java/org/jboss/netty/handler/ssl/SslHandler.java b/src/main/java/org/jboss/netty/handler/ssl/SslHandler.java index 57555de1db..06ea1b8fb1 100644 --- a/src/main/java/org/jboss/netty/handler/ssl/SslHandler.java +++ b/src/main/java/org/jboss/netty/handler/ssl/SslHandler.java @@ -806,13 +806,8 @@ public class SslHandler extends FrameDecoder { if (sentCloseNotify.compareAndSet(false, true)) { engine.closeOutbound(); ChannelFuture closeNotifyFuture = wrapNonAppData(context, e.getChannel()); - closeNotifyFuture.addListener(new ChannelFutureListener() { - public void operationComplete(ChannelFuture closeNotifyFuture) throws Exception { - if (!(closeNotifyFuture.getCause() instanceof ClosedChannelException)) { - Channels.close(context, e.getFuture()); - } - } - }); + closeNotifyFuture.addListener( + new ClosingChannelFutureListener(context, e)); return; } } @@ -842,4 +837,22 @@ public class SslHandler extends FrameDecoder { this.outAppBuf = outAppBuf; } } + + private static final class ClosingChannelFutureListener implements ChannelFutureListener { + + private final ChannelHandlerContext context; + private final ChannelStateEvent e; + + ClosingChannelFutureListener( + ChannelHandlerContext context, ChannelStateEvent e) { + this.context = context; + this.e = e; + } + + public void operationComplete(ChannelFuture closeNotifyFuture) throws Exception { + if (!(closeNotifyFuture.getCause() instanceof ClosedChannelException)) { + Channels.close(context, e.getFuture()); + } + } + } }