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/03/31 18:29:17 UTC

[GitHub] [httpcomponents-core] rschmitt commented on a change in pull request #277: Fixes race condition in the connection lease request logic

rschmitt commented on a change in pull request #277:
URL: https://github.com/apache/httpcomponents-core/pull/277#discussion_r605128093



##########
File path: httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java
##########
@@ -172,7 +175,20 @@ public void close() {
         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);
+        final BasicFuture<PoolEntry<T, C>> future = new BasicFuture<PoolEntry<T, C>>(callback) {
+
+            @Override
+            public synchronized PoolEntry<T, C> get(
+                    final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
+                try {
+                    return super.get(timeout, unit);
+                } catch (final TimeoutException ex) {
+                    cancel();
+                    throw ex;
+                }
+            }
+
+        };

Review comment:
       Bad abstractions are a bigger maintenance burden than duplication.




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