From 64f33aeaa37648928c31b535dd95f4edaa82dfaa Mon Sep 17 00:00:00 2001 From: Dennis Schroer Date: Mon, 31 Jul 2023 14:53:55 +0200 Subject: [PATCH 1/3] Fail with exception on timeout while waiting for connection pool --- .../io/vertx/sqlclient/impl/pool/SqlConnectionPool.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/SqlConnectionPool.java b/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/SqlConnectionPool.java index 9ae5b112a..77e189df9 100644 --- a/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/SqlConnectionPool.java +++ b/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/SqlConnectionPool.java @@ -13,6 +13,7 @@ import io.netty.channel.EventLoop; import io.vertx.core.*; +import io.vertx.core.http.ConnectionPoolTooBusyException; import io.vertx.core.impl.ContextInternal; import io.vertx.core.impl.EventLoopContext; import io.vertx.core.impl.VertxInternal; @@ -217,12 +218,10 @@ public void onEnqueue(PoolWaiter waiter) { if (timeout > 0L && timerID == -1L) { timerID = context.setTimer(timeout, id -> { pool.cancel(waiter, ar -> { - if (ar.succeeded()) { - if (ar.result()) { - handler.handle(Future.failedFuture("Timeout")); - } + if (ar.succeeded() && ar.result()) { + handler.handle(Future.failedFuture(new ConnectionPoolTooBusyException("Timeout while waiting for connection"))); } else { - // ???? + handler.handle(Future.failedFuture(new ConnectionPoolTooBusyException("Failed to cancel pool request after timeout while waiting for connection"))); } }); }); From 4a31c0ae1c8eb156687d790557ef861719419b05 Mon Sep 17 00:00:00 2001 From: Dennis Schroer Date: Mon, 31 Jul 2023 16:34:04 +0200 Subject: [PATCH 2/3] Use TimeoutException --- .../java/io/vertx/sqlclient/impl/pool/SqlConnectionPool.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/SqlConnectionPool.java b/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/SqlConnectionPool.java index 77e189df9..e535a91c3 100644 --- a/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/SqlConnectionPool.java +++ b/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/SqlConnectionPool.java @@ -33,6 +33,7 @@ import io.vertx.sqlclient.spi.DatabaseMetadata; import java.util.List; +import java.util.concurrent.TimeoutException; import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -219,9 +220,9 @@ public void onEnqueue(PoolWaiter waiter) { timerID = context.setTimer(timeout, id -> { pool.cancel(waiter, ar -> { if (ar.succeeded() && ar.result()) { - handler.handle(Future.failedFuture(new ConnectionPoolTooBusyException("Timeout while waiting for connection"))); + handler.handle(Future.failedFuture(new TimeoutException("Timeout while waiting for connection"))); } else { - handler.handle(Future.failedFuture(new ConnectionPoolTooBusyException("Failed to cancel pool request after timeout while waiting for connection"))); + handler.handle(Future.failedFuture(new TimeoutException("Failed to cancel pool request after timeout while waiting for connection"))); } }); }); From 98a6c798d578db662ea2b22b1dc299b906835afd Mon Sep 17 00:00:00 2001 From: Dennis Schroer Date: Mon, 31 Jul 2023 16:35:00 +0200 Subject: [PATCH 3/3] Remove import --- .../java/io/vertx/sqlclient/impl/pool/SqlConnectionPool.java | 1 - 1 file changed, 1 deletion(-) diff --git a/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/SqlConnectionPool.java b/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/SqlConnectionPool.java index e535a91c3..ff6dfd5d5 100644 --- a/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/SqlConnectionPool.java +++ b/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/SqlConnectionPool.java @@ -13,7 +13,6 @@ import io.netty.channel.EventLoop; import io.vertx.core.*; -import io.vertx.core.http.ConnectionPoolTooBusyException; import io.vertx.core.impl.ContextInternal; import io.vertx.core.impl.EventLoopContext; import io.vertx.core.impl.VertxInternal;