hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1100521 - in /httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio: client/ conn/ pool/
Date Sat, 07 May 2011 12:34:10 GMT
Author: olegk
Date: Sat May  7 12:34:10 2011
New Revision: 1100521

URL: http://svn.apache.org/viewvc?rev=1100521&view=rev
Log:
Fixed a very nasty bug in the connection management logic; tweaked logging

Modified:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpClientProtocolHandler.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingClientConnectionManager.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/SessionPool.java

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java?rev=1100521&r1=1100520&r2=1100521&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
Sat May  7 12:34:10 2011
@@ -125,6 +125,7 @@ class DefaultAsyncRequestDirector<T> imp
     private int redirectCount;
     private ByteBuffer tmpbuf;
     private boolean requestContentProduced;
+    private int execCount;
 
     public DefaultAsyncRequestDirector(
             final Log log,
@@ -238,9 +239,6 @@ class DefaultAsyncRequestDirector<T> imp
         this.localContext.setAttribute(ClientContext.PROXY_AUTH_STATE, this.proxyAuthState);
 
         this.httppocessor.process(this.currentRequest, this.localContext);
-        if (this.log.isDebugEnabled()) {
-            this.log.debug("Request submitted: " + this.currentRequest.getRequestLine());
-        }
         this.currentRequest.incrementExecCount();
         if (this.currentRequest.getExecCount() > 1
                 && !this.requestProducer.isRepeatable()
@@ -248,6 +246,10 @@ class DefaultAsyncRequestDirector<T> imp
             throw new NonRepeatableRequestException("Cannot retry request " +
                 "with a non-repeatable request entity.");
         }
+        this.execCount++;
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("Attempt " + this.execCount + " to execute request");
+        }
         return this.currentRequest;
     }
 
@@ -371,6 +373,8 @@ class DefaultAsyncRequestDirector<T> imp
                     this.log.debug("Connection can be kept alive " + s);
                 }
                 this.managedConn.setIdleDuration(duration, TimeUnit.MILLISECONDS);
+            } else {
+                releaseConnection();
             }
 
             if (this.finalResponse != null) {

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpClientProtocolHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpClientProtocolHandler.java?rev=1100521&r1=1100520&r2=1100521&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpClientProtocolHandler.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/NHttpClientProtocolHandler.java
Sat May  7 12:34:10 2011
@@ -346,6 +346,7 @@ class NHttpClientProtocolHandler impleme
             conn.resetInput();
         } else {
             if (!handler.keepAlive(response)) {
+                this.log.debug("Connection cannot be kept alive");
                 conn.close();
             }
         }

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingClientConnectionManager.java?rev=1100521&r1=1100520&r2=1100521&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingClientConnectionManager.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingClientConnectionManager.java
Sat May  7 12:34:10 2011
@@ -96,13 +96,15 @@ public class PoolingClientConnectionMana
     }
 
     public void shutdown(long waitMs) throws IOException {
-        this.log.debug("Connection manager shut down");
+        this.log.debug("Connection manager is shutting down");
         this.pool.shutdown(waitMs);
+        this.log.debug("Connection manager shut down");
     }
 
     public void shutdown() throws IOException {
-        this.log.debug("Connection manager shut down");
+        this.log.debug("Connection manager is shutting down");
         this.pool.shutdown(2000);
+        this.log.debug("Connection manager shut down");
     }
 
     public Future<ManagedClientConnection> leaseConnection(
@@ -155,6 +157,9 @@ public class PoolingClientConnectionMana
         if (manager != null && manager != this) {
             throw new IllegalArgumentException("Connection not obtained from this manager");
         }
+        if (this.pool.isShutdown()) {
+            return;
+        }
         HttpPoolEntry entry = adaptor.getEntry();
         if (this.log.isDebugEnabled()) {
             HttpRoute route = entry.getPlannedRoute();

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/SessionPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/SessionPool.java?rev=1100521&r1=1100520&r2=1100521&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/SessionPool.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/SessionPool.java
Sat May  7 12:34:10 2011
@@ -99,6 +99,10 @@ public abstract class SessionPool<T, E e
         this.maxTotal = maxTotal;
     }
 
+    public boolean isShutdown() {
+        return this.isShutDown;
+    }
+
     public void shutdown(long waitMs) throws IOException {
         if (this.isShutDown) {
             return ;



Mime
View raw message