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 2021/06/21 19:37:12 UTC

[GitHub] [httpcomponents-client] rschmitt commented on a change in pull request #309: Connection lease request cancellation bug

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:
users@infra.apache.org



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