Skip to content

Commit 5e5f8ee

Browse files
committed
Have HTTP client connection pool handle racy uncancellable timeout.
Motivation: The HTTP client connection pool resource acquisition completion can race against the acquisition timeout. Changes: When the acquisition timeout cannot be cancelled, the resource should be recycled and the promise should not be completed.
1 parent 5348c93 commit 5e5f8ee

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

vertx-core/src/main/java/io/vertx/core/http/impl/SharedHttpClientConnectionGroup.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,11 @@ public void onConnect(PoolWaiter<HttpClientConnectionInternal> waiter) {
159159

160160
@Override
161161
public void complete(Lease<HttpClientConnectionInternal> result, Throwable failure) {
162-
if (timerID >= 0) {
163-
context.owner().cancelTimer(timerID);
162+
if (timerID >= 0 && !context.owner().cancelTimer(timerID)) {
163+
result.recycle();
164+
} else {
165+
promise.complete(result, failure);
164166
}
165-
promise.complete(result, failure);
166167
}
167168

168169
void acquire() {

0 commit comments

Comments
 (0)