HTTPCLIENT-1940: deprecated SSLSocketFactory made to rethrow SocketTimeoutException as ConnectTimeoutException for consistency with non-deprecated code

This commit is contained in:
Oleg Kalnichevski 2018-08-11 20:20:25 +02:00
parent 517396df0c
commit 681d11e265
1 changed files with 3 additions and 6 deletions

View File

@ -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) {