rschmitt commented on a change in pull request #309:
URL: 
https://github.com/apache/httpcomponents-client/pull/309#discussion_r655653290



##########
File path: 
httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
##########
@@ -329,7 +331,22 @@ public synchronized ConnectionEndpoint get(
 
             @Override
             public boolean cancel() {
-                return leaseFuture.cancel(true);
+                if (cancelled.compareAndSet(false, true)) {
+                    final boolean result = leaseFuture.cancel(true);
+                    if (!result) {
+                        // The lease request has already completed 
successfully and cannot be cancelled
+                        try {
+                            final PoolEntry<HttpRoute, 
ManagedHttpClientConnection> poolEntry = leaseFuture.get(1, 
TimeUnit.MILLISECONDS);

Review comment:
       I'd prefer to see `leaseFuture.get(0, TimeUnit.MILLISECONDS)` here, by 
way of asserting that this call should not block




-- 
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]



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

Reply via email to