hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r650979 - in /httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl: client/DefaultClientRequestDirector.java conn/SingleClientConnManager.java
Date Wed, 23 Apr 2008 18:23:18 GMT
Author: olegk
Date: Wed Apr 23 11:23:15 2008
New Revision: 650979

URL: http://svn.apache.org/viewvc?rev=650979&view=rev
Log:
Minor code improvements in the DefaultClientRequestRedirector and SingleClientConnManager

Modified:
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java?rev=650979&r1=650978&r2=650979&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
Wed Apr 23 11:23:15 2008
@@ -385,8 +385,7 @@
                 response.setParams(params);
                 requestExec.postProcess(response, httpProcessor, context);
                 
-                RoutedRequest followup =
-                    handleResponse(roureq, wrapper, response, context);
+                RoutedRequest followup = handleResponse(roureq, response, context);
                 if (followup == null) {
                     done = true;
                 } else {
@@ -407,8 +406,6 @@
                     // check if we can use the same connection for the followup
                     if (!followup.getRoute().equals(roureq.getRoute())) {
                         // the followup has a different route, release conn
-                        //@@@ need to consume response body first?
-                        //@@@ or let that be done in handleResponse(...)?
                         connManager.releaseConnection(managedConn);
                         managedConn = null;
                     }
@@ -778,10 +775,7 @@
     /**
      * Analyzes a response to check need for a followup.
      *
-     * @param roureq    the request and route. This is the same object as
-     *                  was passed to {@link #wrapRequest(HttpRequest)}.
-     * @param request   the request that was actually sent. This is the object
-     *                  returned by {@link #wrapRequest(HttpRequest)}.
+     * @param roureq    the request and route. 
      * @param response  the response to analayze
      * @param context   the context used for the current request execution
      *
@@ -792,7 +786,6 @@
      * @throws IOException      in case of an IO problem
      */
     protected RoutedRequest handleResponse(RoutedRequest roureq,
-                                           HttpRequest request,
                                            HttpResponse response,
                                            HttpContext context)
         throws HttpException, IOException {
@@ -800,6 +793,7 @@
         HttpRoute route = roureq.getRoute();
         HttpHost target = route.getTargetHost();
         HttpHost proxy = route.getProxyHost();
+        RequestWrapper request = roureq.getRequest();
         
         HttpParams params = request.getParams();
         if (HttpClientParams.isRedirecting(params) && 
@@ -916,10 +910,6 @@
             // we got here as the result of an exception
             // no response will be returned, release the connection
             managedConn = null;
-            // ensure the connection manager properly releases this connection
-            connManager.releaseConnection(mcc);
-            //@@@ is the connection in a re-usable state? consume response?
-            //@@@ for now, just shut it down
             try {
                 mcc.abortConnection();
             } catch (IOException ex) {
@@ -927,6 +917,8 @@
                     LOG.debug(ex.getMessage(), ex);
                 }
             }
+            // ensure the connection manager properly releases this connection
+            connManager.releaseConnection(mcc);
         }
     } // abortConnection
 

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java?rev=650979&r1=650978&r2=650979&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
Wed Apr 23 11:23:15 2008
@@ -252,12 +252,13 @@
         }
 
         ConnAdapter sca = (ConnAdapter) conn;
-        if (sca.getManager() != this) {
+        if (sca.poolEntry == null)
+            return; // already released
+        ClientConnectionManager manager = sca.getManager();
+        if (manager != null && manager != this) {
             throw new IllegalArgumentException
                 ("Connection not obtained from this manager.");
         }
-        if (sca.poolEntry == null)
-            return; // already released
 
         try {
             // make sure that the response has been read completely



Mime
View raw message