olegk 2004/09/18 04:34:12 Modified: httpclient/src/java/org/apache/commons/httpclient DefaultHttpMethodRetryHandler.java Log: Do not auto-retry methods failed due to a timeout or an SSL handshake error Contributed by Oleg Kalnichevski Revision Changes Path 1.2 +22 -4 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/DefaultHttpMethodRetryHandler.java Index: DefaultHttpMethodRetryHandler.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/DefaultHttpMethodRetryHandler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DefaultHttpMethodRetryHandler.java 5 Jul 2004 22:46:58 -0000 1.1 +++ DefaultHttpMethodRetryHandler.java 18 Sep 2004 11:34:12 -0000 1.2 @@ -30,6 +30,7 @@ package org.apache.commons.httpclient; import java.io.IOException; +import java.io.InterruptedIOException; /** * The default [EMAIL PROTECTED] HttpMethodRetryHandler} used by [EMAIL PROTECTED] HttpMethod}s. @@ -39,7 +40,16 @@ */ public class DefaultHttpMethodRetryHandler implements HttpMethodRetryHandler { - /** the number of times a method will be retried */ + + private static Class SSL_HANDSHAKE_EXCEPTION = null; + + static { + try { + SSL_HANDSHAKE_EXCEPTION = Class.forName("javax.net.ssl.SSLHandshakeException"); + } catch (ClassNotFoundException ignore) { + } + } + /** the number of times a method will be retried */ private int retryCount; /** Whether or not methods that have successfully sent their request will be retried */ @@ -83,6 +93,14 @@ if (exception instanceof NoHttpResponseException) { // Retry if the server dropped connection on us return true; + } + if (exception instanceof InterruptedIOException) { + // Timeout + return false; + } + if (SSL_HANDSHAKE_EXCEPTION != null && SSL_HANDSHAKE_EXCEPTION.isInstance(exception)) { + // SSL handshake exception + return false; } if (!method.isRequestSent() || this.requestSentRetryEnabled) { // Retry if the request has not been sent fully or
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]