From 547a3757374491eef6856c83687e85165a814305 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 5 Apr 2019 09:55:32 +0200 Subject: [PATCH] Always include initial handshake exception when throwing SslHandshakeException (#9008) Motivation: A callback may already have stored a initial handshake exception in ReferenceCountedOpenSslEngine so we should include it when throwing a SslHandshakeException to ensure the user has all the infos when debugging. Modifications: Include initial handshake exception Result: Include all erros when throwing the SslHandshakeException. --- .../netty/handler/ssl/ReferenceCountedOpenSslEngine.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java b/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java index 5526fed753..156ae8babb 100644 --- a/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java +++ b/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java @@ -966,7 +966,14 @@ public class ReferenceCountedOpenSslEngine extends SSLEngine implements Referenc if (handshakeState == HandshakeState.FINISHED) { return new SSLException(errorString); } - return new SSLHandshakeException(errorString); + + SSLHandshakeException exception = new SSLHandshakeException(errorString); + // If we have a handshakeException stored already we should include it as well to help the user debug things. + if (handshakeException != null) { + exception.initCause(handshakeException); + handshakeException = null; + } + return exception; } public final SSLEngineResult unwrap(