From 681d11e265090bf6efa7dd6e19772a746c174b0e Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Sat, 11 Aug 2018 20:20:25 +0200 Subject: [PATCH] HTTPCLIENT-1940: deprecated SSLSocketFactory made to rethrow SocketTimeoutException as ConnectTimeoutException for consistency with non-deprecated code --- .../org/apache/http/conn/ssl/SSLSocketFactory.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java b/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java index 8c7fee5a5..aecbfe14f 100644 --- a/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java +++ b/httpclient/src/main/java-deprecated/org/apache/http/conn/ssl/SSLSocketFactory.java @@ -31,6 +31,7 @@ import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; +import java.net.SocketTimeoutException; import java.net.UnknownHostException; import java.security.KeyManagementException; import java.security.KeyStore; @@ -540,12 +541,8 @@ public class SSLSocketFactory implements LayeredConnectionSocketFactory, SchemeL } try { sock.connect(remoteAddress, connectTimeout); - } catch (final IOException ex) { - try { - sock.close(); - } catch (final IOException ignore) { - } - throw ex; + } catch (final SocketTimeoutException ex) { + throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out"); } // Setup SSL layering if necessary if (sock instanceof SSLSocket) {