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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to