Author: olegk
Date: Tue Mar 29 13:25:44 2005
New Revision: 159425

URL: http://svn.apache.org/viewcvs?view=rev&rev=159425
Log:
PR #33677 (Retry on ConnectionException does not work)

Contributed by Oleg Kalnichevski
Reviewed by Michael Becke

Modified:
    
jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodDirector.java

Modified: 
jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodDirector.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodDirector.java?view=diff&r1=159424&r2=159425
==============================================================================
--- 
jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodDirector.java
 (original)
+++ 
jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodDirector.java
 Tue Mar 29 13:25:44 2005
@@ -329,6 +329,27 @@
     
     
     /**
+     * Applies connection parameters specified for a given method
+     * 
+     * @param method HTTP method
+     * 
+     * @throws IOException if an I/O occurs setting connection parameters 
+     */
+    private void applyConnectionParams(final HttpMethod method) throws 
IOException {
+        int timeout = 0;
+        // see if a timeout is given for this method
+        Object param = 
method.getParams().getParameter(HttpMethodParams.SO_TIMEOUT);
+        if (param == null) {
+            // if not, use the default value
+            param = 
this.conn.getParams().getParameter(HttpConnectionParams.SO_TIMEOUT);
+        }
+        if (param != null) {
+            timeout = ((Integer)param).intValue();
+        }
+        this.conn.setSocketTimeout(timeout);                    
+    }
+    
+    /**
      * Executes a method with the current hostConfiguration.
      *
      * @throws IOException if an I/O (transport) error occurs. Some transport 
exceptions 
@@ -346,39 +367,28 @@
         try {
             while (true) {
                 execCount++;
+                try {
 
-                if (LOG.isTraceEnabled()) {
-                    LOG.trace("Attempt number " + execCount + " to process 
request");
-                }
-                if (this.conn.getParams().isStaleCheckingEnabled()) {
-                    this.conn.closeIfStale();
-                }
-                if (!this.conn.isOpen()) {
-                    // this connection must be opened before it can be used
-                    // This has nothing to do with opening a secure tunnel
-                    this.conn.open();
-                    if (this.conn.isProxied() && this.conn.isSecure() 
-                    && !(method instanceof ConnectMethod)) {
-                        // we need to create a secure tunnel before we can 
execute the real method
-                        if (!executeConnect()) {
-                            // abort, the connect method failed
-                            return;
+                    if (LOG.isTraceEnabled()) {
+                        LOG.trace("Attempt number " + execCount + " to process 
request");
+                    }
+                    if (this.conn.getParams().isStaleCheckingEnabled()) {
+                        this.conn.closeIfStale();
+                    }
+                    if (!this.conn.isOpen()) {
+                        // this connection must be opened before it can be used
+                        // This has nothing to do with opening a secure tunnel
+                        this.conn.open();
+                        if (this.conn.isProxied() && this.conn.isSecure() 
+                        && !(method instanceof ConnectMethod)) {
+                            // we need to create a secure tunnel before we can 
execute the real method
+                            if (!executeConnect()) {
+                                // abort, the connect method failed
+                                return;
+                            }
                         }
                     }
-                }
-                int timeout = 0;
-                // see if a timeout is given for this method
-                Object param = 
method.getParams().getParameter(HttpMethodParams.SO_TIMEOUT);
-                if (param == null) {
-                    // if not, use the default value
-                    param = 
this.conn.getParams().getParameter(HttpConnectionParams.SO_TIMEOUT);
-                }
-                if (param != null) {
-                    timeout = ((Integer)param).intValue();
-                }
-                this.conn.setSocketTimeout(timeout);
-                
-                try {
+                    applyConnectionParams(method);                    
                     method.execute(state, this.conn);
                     break;
                 } catch (HttpException e) {
@@ -467,7 +477,8 @@
             } catch (AuthenticationException e) {
                 LOG.error(e.getMessage(), e);
             }
-            executeWithRetry(this.connectMethod);
+            applyConnectionParams(this.connectMethod);                    
+            this.connectMethod.execute(state, this.conn);
             code = this.connectMethod.getStatusCode();
             boolean retry = false;
             AuthState authstate = this.connectMethod.getProxyAuthState(); 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to