hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [11/19] httpcomponents-core git commit: HTTPCORE-463: Fixed incorrect use of connect timeout setting in AbstractNIOConnPool
Date Fri, 12 May 2017 08:04:35 GMT
HTTPCORE-463: Fixed incorrect use of connect timeout setting in AbstractNIOConnPool

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.4.x@1794129
13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/0cc398f5
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/0cc398f5
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/0cc398f5

Branch: refs/heads/4.4.x
Commit: 0cc398f50136e272fa71717df8e8a8b12cccaf38
Parents: 51128f6
Author: Oleg Kalnichevski <olegk@apache.org>
Authored: Sat May 6 09:07:54 2017 +0000
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Fri May 12 09:50:04 2017 +0200

----------------------------------------------------------------------
 .../org/apache/http/nio/pool/AbstractNIOConnPool.java  | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/0cc398f5/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
b/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
index 77824b4..3025fac 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
@@ -272,8 +272,10 @@ public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T,
C>>
         final BasicFuture<E> future = new BasicFuture<E>(callback);
         this.lock.lock();
         try {
-            final long timeout = connectTimeout > 0 ? tunit.toMillis(connectTimeout) :
0;
-            final LeaseRequest<T, C, E> request = new LeaseRequest<T, C, E>(route,
state, timeout, leaseTimeout, future);
+            final LeaseRequest<T, C, E> request = new LeaseRequest<T, C, E>(route,
state,
+                    connectTimeout >= 0 ? tunit.toMillis(connectTimeout) : -1,
+                    leaseTimeout > 0 ? tunit.toMillis(leaseTimeout) : 0,
+                    future);
             final boolean completed = processPendingRequest(request);
             if (!request.isDone() && !completed) {
                 this.leasingRequests.add(request);
@@ -444,9 +446,10 @@ public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T,
C>>
 
             final SessionRequest sessionRequest = this.ioreactor.connect(
                     remoteAddress, localAddress, route, this.sessionRequestCallback);
-            final int timout = request.getConnectTimeout() < Integer.MAX_VALUE ?
-                    (int) request.getConnectTimeout() : Integer.MAX_VALUE;
-            sessionRequest.setConnectTimeout(timout);
+            final long connectTimeout = request.getConnectTimeout();
+            if (connectTimeout >= 0) {
+                sessionRequest.setConnectTimeout(connectTimeout < Integer.MAX_VALUE ?
(int) connectTimeout : Integer.MAX_VALUE);
+            }
             this.pending.add(sessionRequest);
             pool.addPending(sessionRequest, request.getFuture());
             return true;


Mime
View raw message