GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Port 5.0: Call `handshakeFailure` for TLS timeouts and early closes (… · netty/netty@a5e0bef

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • handler/src
    • main/java/io/netty/handler/ssl
      • ApplicationProtocolNegotiationHandler.java
    • test/java/io/netty/handler/ssl
      • ApplicationProtocolNegotiationHandlerTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: handler/src/main/java/io/netty/handler/ssl/ApplicationProtocolNegotiationHandler.java
+23-13Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import io.netty.util.internal.logging.InternalLogger;
2828
import io.netty.util.internal.logging.InternalLoggerFactory;
2929

30+
import java.nio.channels.ClosedChannelException;
3031
import javax.net.ssl.SSLException;
3132

3233
/**
@@ -144,19 +145,24 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exc
144145
String protocol = sslHandler.applicationProtocol();
145146
configurePipeline(ctx, protocol != null ? protocol : fallbackProtocol);
146147
} else {
147-
try {
148-
ctx.fireUserEventTriggered(evt);
149-
} finally {
150-
this.notifyHandshakeFailure(ctx, handshakeEvent.cause());
148+
// timeouts and early closes may not produce a decoder exception
149+
// preserve the existing exception and close handling for other TLS failures
150+
Throwable cause = handshakeEvent.cause();
151+
if (cause instanceof SslHandshakeTimeoutException || cause instanceof ClosedChannelException) {
152+
try {
153+
ctx.fireUserEventTriggered(evt);
154+
} finally {
155+
notifyHandshakeFailure(ctx, cause);
156+
}
157+
158+
return;
151159
}
152-
153-
return;
154160
}
155161
} catch (Throwable cause) {
156162
exceptionCaught(ctx, cause);
157163
} finally {
158-
// consume later SSL decoder exceptions to avoid downstream warnings
159-
// see https://github.com/netty/netty/issues/10342; timeouts and early closes may only emit this event
164+
// keep the handler after failure to consume later SSL decoder exceptions
165+
// see https://github.com/netty/netty/issues/10342
160166
if (handshakeEvent.isSuccess()) {
161167
removeSelfIfPresent(ctx);
162168
}
@@ -198,9 +204,14 @@ protected void handshakeFailure(ChannelHandlerContext ctx, Throwable cause) thro
198204
}
199205

200206
private void notifyHandshakeFailure(ChannelHandlerContext ctx, Throwable cause) throws Exception {
201-
if (!this.handshakeFailed) {
202-
this.handshakeFailed = true;
203-
this.handshakeFailure(ctx, cause);
207+
if (!handshakeFailed) {
208+
handshakeFailed = true;
209+
210+
try {
211+
handshakeFailure(ctx, cause);
212+
} catch (Throwable innerCause) {
213+
exceptionCaught(ctx, innerCause);
214+
}
204215
}
205216
}
206217

@@ -209,13 +220,12 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
209220
Throwable wrapped;
210221
if (cause instanceof DecoderException && ((wrapped = cause.getCause()) instanceof SSLException)) {
211222
try {
212-
this.notifyHandshakeFailure(ctx, wrapped);
223+
notifyHandshakeFailure(ctx, wrapped);
213224
return;
214225
} finally {
215226
removeSelfIfPresent(ctx);
216227
}
217228
}
218-
219229
logger.warn("{} Failed to select the application-level protocol:", ctx.channel(), cause);
220230
ctx.fireExceptionCaught(cause);
221231
ctx.close();

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.