Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StacklessSSLHandshakeException: add a short stack-trace #13315

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions handler/src/main/java/io/netty/handler/ssl/SslHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1068,8 +1068,9 @@ public void channelInactive(ChannelHandlerContext ctx) throws Exception {

// Add a supressed exception if the handshake was not completed yet.
if (isStateSet(STATE_HANDSHAKE_STARTED) && !handshakePromise.isDone()) {
ThrowableUtil.addSuppressed(exception,
new StacklessSSLHandshakeException("Connection closed while SSL/TLS handshake was in progress"));
ThrowableUtil.addSuppressed(exception, StacklessSSLHandshakeException.newInstance(
"Connection closed while SSL/TLS handshake was in progress",
SslHandler.class, "channelInactive"));
}

// Make sure to release SSLEngine,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package io.netty.handler.ssl;

import io.netty.util.internal.ThrowableUtil;

import javax.net.ssl.SSLHandshakeException;

/**
Expand All @@ -24,13 +26,7 @@ final class StacklessSSLHandshakeException extends SSLHandshakeException {

private static final long serialVersionUID = -1244781947804415549L;

/**
* Constructs an exception reporting an error found by
* an SSL subsystem during handshaking.
*
* @param reason describes the problem.
*/
StacklessSSLHandshakeException(String reason) {
private StacklessSSLHandshakeException(String reason) {
super(reason);
}

Expand All @@ -40,4 +36,11 @@ public Throwable fillInStackTrace() {
// stack trace as this is a stackless exception.
return this;
}

/**
* Creates a new {@link StacklessSSLHandshakeException} which has the origin of the given {@link Class} and method.
*/
static StacklessSSLHandshakeException newInstance(String reason, Class<?> clazz, String method) {
return ThrowableUtil.unknownStackTrace(new StacklessSSLHandshakeException(reason), clazz, method);
}
}