You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2023/07/06 07:58:31 UTC

[httpcomponents-core] 02/02: HTTPCORE-754: StrictConnPool fails to correctly handle infinite request timeout

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit aa5bdbbbce7385e67de585c86cb34155b7cb1bd2
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Fri Jun 30 17:45:52 2023 +0200

    HTTPCORE-754: StrictConnPool fails to correctly handle infinite request timeout
---
 .../src/main/java/org/apache/hc/core5/pool/StrictConnPool.java     | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java b/httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java
index 9801cf82e..0ac5faca3 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java
@@ -192,7 +192,12 @@ public class StrictConnPool<T, C extends ModalCloseable> implements ManagedConnP
         final boolean acquiredLock;
 
         try {
-            acquiredLock = this.lock.tryLock(requestTimeout.getDuration(), requestTimeout.getTimeUnit());
+            if (Timeout.isPositive(requestTimeout)) {
+                acquiredLock = this.lock.tryLock(requestTimeout.getDuration(), requestTimeout.getTimeUnit());
+            } else {
+                this.lock.lockInterruptibly();
+                acquiredLock = true;
+            }
         } catch (final InterruptedException interruptedException) {
             Thread.currentThread().interrupt();
             future.cancel();