Skip to content

Commit 4219ed4

Browse files
committed
ApplicationProtocolNegotiationHandler failure behavior
Motivation: Child classes of ApplicationProtocolNegotiationHandler may want to override the behavior when a handshake failure is detected. Modifications: - Provide a method which can be overriden when a handshake failure is detected. Result: Child classes can override ApplicationProtocolNegotiationHandler handshake failure behavior.
1 parent 1cdf0cb commit 4219ed4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

handler/src/main/java/io/netty/handler/ssl/ApplicationProtocolNegotiationHandler.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exc
9999
String protocol = sslHandler.applicationProtocol();
100100
configurePipeline(ctx, protocol != null? protocol : fallbackProtocol);
101101
} else {
102-
logger.warn("{} TLS handshake failed:", ctx.channel(), handshakeEvent.cause());
103-
ctx.close();
102+
handshakeFailure(ctx, handshakeEvent.cause());
104103
}
105104
}
106105

@@ -117,6 +116,14 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exc
117116
*/
118117
protected abstract void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception;
119118

119+
/**
120+
* Invoked on failed initial SSL/TLS handshake.
121+
*/
122+
protected void handshakeFailure(ChannelHandlerContext ctx, Throwable cause) throws Exception {
123+
logger.warn("{} TLS handshake failed:", ctx.channel(), cause);
124+
ctx.close();
125+
}
126+
120127
@Override
121128
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
122129
logger.warn("{} Failed to select the application-level protocol:", ctx.channel(), cause);

0 commit comments

Comments
 (0)