Index: httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java (revision 1351685) +++ httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java (revision ) @@ -31,6 +31,8 @@ import java.io.InterruptedIOException; import java.net.ConnectException; import java.net.UnknownHostException; +import java.util.HashSet; +import java.util.Set; import javax.net.ssl.SSLException; @@ -58,6 +60,8 @@ /** Whether or not methods that have successfully sent their request will be retried */ private final boolean requestSentRetryEnabled; + private final Set> rejectExceptions = new HashSet>(); + /** * Default constructor */ @@ -65,6 +69,10 @@ super(); this.retryCount = retryCount; this.requestSentRetryEnabled = requestSentRetryEnabled; + rejectExceptions.add(InterruptedIOException.class); + rejectExceptions.add(UnknownHostException.class); + rejectExceptions.add(ConnectException.class); + rejectExceptions.add(SSLException.class); } /** @@ -91,27 +99,17 @@ // Do not retry if over max retry count return false; } - if (exception instanceof InterruptedIOException) { - // Timeout + + for (Class rejectException : rejectExceptions) { + if (rejectException.isInstance(exception)) { - return false; - } + return false; + } - if (exception instanceof UnknownHostException) { - // Unknown host - return false; } - if (exception instanceof ConnectException) { - // Connection refused - return false; - } - if (exception instanceof SSLException) { - // SSL handshake exception - return false; - } HttpRequest request = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST); - if(requestIsAborted(request)){ + if (requestIsAborted(request)) { return false; } @@ -166,4 +164,10 @@ return (req instanceof HttpUriRequest && ((HttpUriRequest)req).isAborted()); } + /** + * Allow sub-classes to modify the Set of IOExceptions that will be rejected for retry. + */ + protected Set> getRejectExceptions() { + return rejectExceptions; + } }