From 382f8eacaf71a37db8675e9dd3a6a98c2cfb9b4e Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Thu, 11 Aug 2016 21:21:34 +0200 Subject: [PATCH] Correctly fail all promises SSLENGINE_CLOSED once the engine is closed Motivation: We should fail all promises with the correct SSLENGINE_CLOSED exception one the engine is closed. We did not fail the current promise with this exception if the ByteBuf was not readable. Modifications: Correctly fail promises. Result: More correct handling of promises if the SSLEngine is closed. --- .../main/java/io/netty/handler/ssl/SslHandler.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 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 a5f1eb0829..57e67454e1 100644 --- a/handler/src/main/java/io/netty/handler/ssl/SslHandler.java +++ b/handler/src/main/java/io/netty/handler/ssl/SslHandler.java @@ -514,11 +514,6 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH } SSLEngineResult result = wrap(alloc, engine, buf, out); - if (!buf.isReadable()) { - promise = pendingUnencryptedWrites.remove(); - } else { - promise = null; - } if (result.getStatus() == Status.CLOSED) { // SSLEngine has been closed already. @@ -526,6 +521,12 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH pendingUnencryptedWrites.removeAndFailAll(SSLENGINE_CLOSED); return; } else { + if (!buf.isReadable()) { + promise = pendingUnencryptedWrites.remove(); + } else { + promise = null; + } + switch (result.getHandshakeStatus()) { case NEED_TASK: runDelegatedTasks();