You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by GitBox <gi...@apache.org> on 2019/12/11 10:59:16 UTC

[GitHub] [httpcomponents-core] ok2c commented on a change in pull request #163: Allow for timeout while acquiring lock in StrictConnPool.

ok2c commented on a change in pull request #163: Allow for timeout while acquiring lock in StrictConnPool.
URL: https://github.com/apache/httpcomponents-core/pull/163#discussion_r356529011
 
 

 ##########
 File path: httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java
 ##########
 @@ -171,21 +171,33 @@ public void close() {
         Args.notNull(route, "Route");
         Args.notNull(requestTimeout, "Request timeout");
         Asserts.check(!this.isShutDown.get(), "Connection pool shut down");
+        final Deadline deadline = Deadline.calculate(requestTimeout);
         final BasicFuture<PoolEntry<T, C>> future = new BasicFuture<>(callback);
-        this.lock.lock();
+        boolean acquiredLock = false;
+
         try {
-            final LeaseRequest<T, C> request = new LeaseRequest<>(route, state, requestTimeout, future);
-            final boolean completed = processPendingRequest(request);
-            if (!request.isDone() && !completed) {
-                this.leasingRequests.add(request);
-            }
-            if (request.isDone()) {
-                this.completedRequests.add(request);
+            acquiredLock = this.lock.tryLock(requestTimeout.getDuration(), requestTimeout.getTimeUnit());
+        } catch (final InterruptedException ignored) {
 
 Review comment:
   @cwildman `InterruptedException` handling logic does not look quite right to me. At the very least one must call                 `Thread.currentThread().interrupt()` when catching and not re-throwing `InterruptedException`. I also think we should either cancel request at that point or propagate the exception to the caller. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org