hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <oleg.kalnichev...@bearingpoint.com>
Subject [PATCH] Do not auto-retry methods failed due to a timeout or an SSL handshake error
Date Fri, 17 Sep 2004 12:06:14 GMT

Folks,
Here's a small patch that tweaks the default method retry handler a
little. Currently HttpClient 3.0 stubbornly reties method that fail due
to a timeout or an SSL handshake exception, which is not the way it
probably should be.

Unless I hear loud complaints, I'll apply the patch tonight at 21:00GMT

Oleg

Index: DefaultHttpMethodRetryHandler.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/DefaultHttpMethodRetryHandler.java,v
retrieving revision 1.1
diff -u -r1.1 DefaultHttpMethodRetryHandler.java
--- DefaultHttpMethodRetryHandler.java	5 Jul 2004 22:46:58 -0000	1.1
+++ DefaultHttpMethodRetryHandler.java	17 Sep 2004 11:50:37 -0000
@@ -30,6 +30,7 @@
 package org.apache.commons.httpclient;
 
 import java.io.IOException;
+import java.io.InterruptedIOException;
 
 /**
  * The default {@link HttpMethodRetryHandler} used by {@link
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
 


***************************************************************************************************
The information in this email is confidential and may be legally privileged.  Access to this
email by anyone other than the intended addressee is unauthorized.  If you are not the intended
recipient of this message, any review, disclosure, copying, distribution, retention, or any
action taken or omitted to be taken in reliance on it is prohibited and may be unlawful. 
If you are not the intended recipient, please reply to or forward a copy of this message to
the sender and delete the message, any attachments, and any copies thereof from your system.
***************************************************************************************************
Mime
View raw message