Skip to content

Commit 4d5a856

Browse files
committed
Don't stall when failing to create SslHandler, close AsyncHttpClient#1361
Motivation: Creating a SslHandler can crash, for example when there's a typo in the enabled protocols. When this happens, the exception is not propagated. Modification: Catch such Exception and notify the NettyConnectListener. Result: AHC no longer stalled when such exception happens.
1 parent 9bc0d30 commit 4d5a856

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

client/src/main/java/org/asynchttpclient/netty/channel/NettyConnectListener.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ public void onSuccess(Channel channel, InetSocketAddress remoteAddress) {
110110

111111
// in case of proxy tunneling, we'll add the SslHandler later, after the CONNECT request
112112
if (future.getProxyServer() == null && uri.isSecured()) {
113-
SslHandler sslHandler = channelManager.addSslHandler(channel.pipeline(), uri, request.getVirtualHost());
113+
SslHandler sslHandler = null;
114+
try {
115+
sslHandler = channelManager.addSslHandler(channel.pipeline(), uri, request.getVirtualHost());
116+
} catch (Exception sslError) {
117+
NettyConnectListener.this.onFailure(channel, sslError);
118+
return;
119+
}
114120

115121
final AsyncHandlerExtensions asyncHandlerExtensions = toAsyncHandlerExtensions(future.getAsyncHandler());
116122

0 commit comments

Comments
 (0)