You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2011/03/10 10:42:11 UTC

svn commit: r1080167 - in /httpcomponents/httpclient/trunk: ./ RELEASE_NOTES.txt httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java

Author: olegk
Date: Thu Mar 10 09:42:11 2011
New Revision: 1080167

URL: http://svn.apache.org/viewvc?rev=1080167&view=rev
Log:
Merged fixes from 4.1.x branches

Modified:
    httpcomponents/httpclient/trunk/   (props changed)
    httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java

Propchange: httpcomponents/httpclient/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Mar 10 09:42:11 2011
@@ -1,3 +1,4 @@
 /httpcomponents/httpclient/branches/4.0.x:950681-950688
+/httpcomponents/httpclient/branches/4.1.x:1079518-1080165
 /httpcomponents/httpclient/branches/branch_4_1:755593-811107
 /httpcomponents/httpclient/branches/notice-plugin-test:1024348-1031454

Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=1080167&r1=1080166&r2=1080167&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Thu Mar 10 09:42:11 2011
@@ -1,5 +1,9 @@
 Changes since 4.1
 
+* [HTTPCLIENT-1069] HttpHostConnectException not correctly retried for direct and non-tunnelled 
+  proxy connections. 
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCLIENT-1066] Changed the way URIUtils#rewriteURI handles multiple consecutive slashes in the
   URI path component: multiple leading slashes will be replaced by one slash in order to avoid
   confusion with the authority component. The remaining content of the path will not be modified. 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java?rev=1080167&r1=1080166&r2=1080167&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java Thu Mar 10 09:42:11 2011
@@ -340,12 +340,12 @@ public class SSLSocketFactory implements
      * @since 4.1
      */
     public Socket createSocket(final HttpParams params) throws IOException {
-        return new Socket();
+        return this.socketfactory.createSocket();
     }
 
     @Deprecated
     public Socket createSocket() throws IOException {
-        return new Socket();
+        return this.socketfactory.createSocket();
     }
 
     /**

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java?rev=1080167&r1=1080166&r2=1080167&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java Thu Mar 10 09:42:11 2011
@@ -552,9 +552,8 @@ public class DefaultRequestDirector impl
             final RoutedRequest req, final HttpContext context) throws HttpException, IOException {
         HttpRoute route = req.getRoute();
 
-        boolean retrying = true;
         int connectCount = 0;
-        while (retrying) {
+        for (;;) {
             // Increment connect count
             connectCount++;
             try {
@@ -564,7 +563,7 @@ public class DefaultRequestDirector impl
                     managedConn.setSocketTimeout(HttpConnectionParams.getSoTimeout(params));
                 }
                 establishRoute(route, context);
-                retrying = false;
+                break;
             } catch (IOException ex) {
                 try {
                     managedConn.close();
@@ -596,9 +595,8 @@ public class DefaultRequestDirector impl
         HttpRoute route = req.getRoute();
         HttpResponse response = null;
 
-        boolean retrying = true;
         Exception retryReason = null;
-        while (retrying) {
+        for (;;) {
             // Increment total exec count (with redirects)
             execCount++;
             // Increment exec count for this particular request
@@ -616,11 +614,24 @@ public class DefaultRequestDirector impl
             }
 
             try {
+                if (!managedConn.isOpen()) {
+                    // If we have a direct route to the target host
+                    // just re-open connection and re-try the request
+                    if (!route.isTunnelled()) {
+                        this.log.debug("Reopening the direct connection.");
+                        managedConn.open(route, context, params);
+                    } else {
+                        // otherwise give up
+                        this.log.debug("Proxied connection. Need to start over.");
+                        break;
+                    }
+                }
+
                 if (this.log.isDebugEnabled()) {
                     this.log.debug("Attempt " + execCount + " to execute request");
                 }
                 response = requestExec.execute(wrapper, managedConn, context);
-                retrying = false;
+                break;
 
             } catch (IOException ex) {
                 this.log.debug("Closing the connection.");
@@ -642,18 +653,6 @@ public class DefaultRequestDirector impl
                 } else {
                     throw ex;
                 }
-
-                // If we have a direct route to the target host
-                // just re-open connection and re-try the request
-                if (!route.isTunnelled()) {
-                    this.log.debug("Reopening the direct connection.");
-                    managedConn.open(route, context, params);
-                } else {
-                    // otherwise give up
-                    this.log.debug("Proxied connection. Need to start over.");
-                    retrying = false;
-                }
-
             }
         }
         return response;