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 f41d88b991..63561a35f8 100644 --- a/handler/src/main/java/io/netty/handler/ssl/SslHandler.java +++ b/handler/src/main/java/io/netty/handler/ssl/SslHandler.java @@ -189,8 +189,6 @@ public class SslHandler private volatile long handshakeTimeoutMillis = 10000; private volatile long closeNotifyTimeoutMillis = 3000; - private static final SslHandshakeCompletionEvent HANDSHAKE_SUCCESS_EVENT = new SslHandshakeCompletionEvent(null); - /** * Creates a new instance. * @@ -908,7 +906,7 @@ public class SslHandler */ private void setHandshakeSuccess() { if (handshakePromise.trySuccess(ctx.channel())) { - ctx.fireUserEventTriggered(HANDSHAKE_SUCCESS_EVENT); + ctx.fireUserEventTriggered(SslHandshakeCompletionEvent.SUCCESS); } } diff --git a/handler/src/main/java/io/netty/handler/ssl/SslHandshakeCompletionEvent.java b/handler/src/main/java/io/netty/handler/ssl/SslHandshakeCompletionEvent.java index 547f9fc352..8e4985853d 100644 --- a/handler/src/main/java/io/netty/handler/ssl/SslHandshakeCompletionEvent.java +++ b/handler/src/main/java/io/netty/handler/ssl/SslHandshakeCompletionEvent.java @@ -22,9 +22,25 @@ package io.netty.handler.ssl; */ public final class SslHandshakeCompletionEvent { + public static final SslHandshakeCompletionEvent SUCCESS = new SslHandshakeCompletionEvent(); + private final Throwable cause; + /** + * Creates a new event that indicates a successful handshake. + */ + private SslHandshakeCompletionEvent() { + cause = null; + } + + /** + * Creates a new event that indicates an unsuccessful handshake. + * Use {@link #SUCCESS} to indicate a successful handshake. + */ public SslHandshakeCompletionEvent(Throwable cause) { + if (cause == null) { + throw new NullPointerException("cause"); + } this.cause = cause; }