From 6e2593ddc33a261c0a6212cc71c55cc29e7d530a Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Thu, 14 Nov 2013 15:08:10 +0900 Subject: [PATCH] Fix regression introduced by 4c7fa950cc4f4c52eeaae5887335b1f3047592f8 - Some promises were not fulfilled when SSLEngine produces 0 bytes. --- .../java/io/netty/handler/ssl/SslHandler.java | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 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 4ebdd410a0..aaefc0e5b0 100644 --- a/handler/src/main/java/io/netty/handler/ssl/SslHandler.java +++ b/handler/src/main/java/io/netty/handler/ssl/SslHandler.java @@ -490,24 +490,21 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH } private void finishWrap(ChannelHandlerContext ctx, ByteBuf out, ChannelPromise promise, boolean inUnwrap) { - if (out != null) { - if (out.isReadable()) { - if (promise != null) { - ctx.write(out, promise); - } else { - ctx.write(out); - } - if (inUnwrap) { - needsFlush = true; - } - } else { - out.release(); - } - } else if (promise != null) { - ctx.write(Unpooled.EMPTY_BUFFER, promise); - if (inUnwrap) { - needsFlush = true; - } + if (out == null) { + out = Unpooled.EMPTY_BUFFER; + } else if (!out.isReadable()) { + out.release(); + out = Unpooled.EMPTY_BUFFER; + } + + if (promise != null) { + ctx.write(out, promise); + } else { + ctx.write(out); + } + + if (inUnwrap) { + needsFlush = true; } }