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 80277ebb85..5b898866b7 100644 --- a/handler/src/main/java/io/netty/handler/ssl/SslHandler.java +++ b/handler/src/main/java/io/netty/handler/ssl/SslHandler.java @@ -300,9 +300,10 @@ public class SslHandler } SSLException e = new SSLException("handshake timed out"); - future.setFailure(e); - ctx.fireExceptionCaught(e); - ctx.close(); + if ( future.setFailure(e) ){ + ctx.fireExceptionCaught(e); + ctx.close(); + } } }, handshakeTimeoutMillis, TimeUnit.MILLISECONDS); } else { @@ -320,9 +321,10 @@ public class SslHandler handshakeFutures.add(future); flush(ctx, ctx.newFuture()); } catch (Exception e) { - future.setFailure(e); - ctx.fireExceptionCaught(e); - ctx.close(); + if ( future.setFailure(e) ) { + ctx.fireExceptionCaught(e); + ctx.close(); + } } } });