From f46f60289a2d08f6404ee3fccfd9a8593d7f6db1 Mon Sep 17 00:00:00 2001 From: Jorge Bescos Gascon Date: Mon, 21 Jun 2021 10:55:37 +0200 Subject: [PATCH] Connection timeout the double of what is configured Signed-off-by: Jorge Bescos Gascon --- .../glassfish/jersey/client/internal/HttpUrlConnector.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core-client/src/main/java/org/glassfish/jersey/client/internal/HttpUrlConnector.java b/core-client/src/main/java/org/glassfish/jersey/client/internal/HttpUrlConnector.java index 21456b9c2e..443c8573ed 100644 --- a/core-client/src/main/java/org/glassfish/jersey/client/internal/HttpUrlConnector.java +++ b/core-client/src/main/java/org/glassfish/jersey/client/internal/HttpUrlConnector.java @@ -22,6 +22,7 @@ import java.lang.reflect.Field; import java.net.HttpURLConnection; import java.net.ProtocolException; +import java.net.SocketTimeoutException; import java.net.URI; import java.net.URISyntaxException; import java.security.AccessController; @@ -541,7 +542,11 @@ private IOException handleException(ClientRequest request, IOException ex, HttpU if (connectorExtension.handleException(request, uc, ex)) { return null; } - if (uc.getResponseCode() == -1) { + /* + * uc.getResponseCode triggers another request. If we already know it is a SocketTimeoutException + * we can throw the exception directly. Otherwise the request will be 2 * timeout. + */ + if (ex instanceof SocketTimeoutException || uc.getResponseCode() == -1) { throw ex; } else { return ex;