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 2017/01/28 10:34:41 UTC

svn commit: r1780653 - /httpcomponents/httpcore/branches/4.4.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java

Author: olegk
Date: Sat Jan 28 10:34:41 2017
New Revision: 1780653

URL: http://svn.apache.org/viewvc?rev=1780653&view=rev
Log:
HTTPASYNC-116: Remove cancelled lease requests from the request queue when validating pending requests

Modified:
    httpcomponents/httpcore/branches/4.4.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java

Modified: httpcomponents/httpcore/branches/4.4.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java?rev=1780653&r1=1780652&r2=1780653&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java (original)
+++ httpcomponents/httpcore/branches/4.4.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java Sat Jan 28 10:34:41 2017
@@ -484,11 +484,18 @@ public abstract class AbstractNIOConnPoo
             final ListIterator<LeaseRequest<T, C, E>> it = this.leasingRequests.listIterator();
             while (it.hasNext()) {
                 final LeaseRequest<T, C, E> request = it.next();
-                final long deadline = request.getDeadline();
-                if (now > deadline) {
+                final BasicFuture<E> future = request.getFuture();
+                if (future.isCancelled() && !request.isDone()) {
                     it.remove();
-                    request.failed(new TimeoutException());
-                    this.completedRequests.add(request);
+                } else {
+                    final long deadline = request.getDeadline();
+                    if (now > deadline) {
+                        request.failed(new TimeoutException());
+                    }
+                    if (request.isDone()) {
+                        it.remove();
+                        this.completedRequests.add(request);
+                    }
                 }
             }
         } finally {