Skip to content

Commit 994f719

Browse files
committed
Fail with exception on timeout while waiting for connection pool
1 parent 9073da6 commit 994f719

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/SqlConnectionPool.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import io.netty.channel.EventLoop;
1515
import io.vertx.core.*;
16+
import io.vertx.core.http.ConnectionPoolTooBusyException;
1617
import io.vertx.core.impl.ContextInternal;
1718
import io.vertx.core.impl.EventLoopContext;
1819
import io.vertx.core.impl.VertxInternal;
@@ -22,6 +23,7 @@
2223
import io.vertx.core.spi.metrics.ClientMetrics;
2324
import io.vertx.core.spi.tracing.VertxTracer;
2425
import io.vertx.core.tracing.TracingPolicy;
26+
import io.vertx.sqlclient.DatabaseException;
2527
import io.vertx.sqlclient.SqlConnection;
2628
import io.vertx.sqlclient.impl.Connection;
2729
import io.vertx.sqlclient.impl.SqlConnectionBase;
@@ -31,6 +33,7 @@
3133
import io.vertx.sqlclient.spi.ConnectionFactory;
3234
import io.vertx.sqlclient.spi.DatabaseMetadata;
3335

36+
import java.sql.SQLTimeoutException;
3437
import java.util.List;
3538
import java.util.function.Function;
3639
import java.util.function.Supplier;
@@ -217,12 +220,10 @@ public void onEnqueue(PoolWaiter<PooledConnection> waiter) {
217220
if (timeout > 0L && timerID == -1L) {
218221
timerID = context.setTimer(timeout, id -> {
219222
pool.cancel(waiter, ar -> {
220-
if (ar.succeeded()) {
221-
if (ar.result()) {
222-
handler.handle(Future.failedFuture("Timeout"));
223-
}
223+
if (ar.succeeded() && ar.result()) {
224+
handler.handle(Future.failedFuture(new ConnectionPoolTooBusyException("Timeout while waiting for connection")));
224225
} else {
225-
// ????
226+
handler.handle(Future.failedFuture(new ConnectionPoolTooBusyException("Failed to cancel pool request after timeout while waiting for connection")));
226227
}
227228
});
228229
});

0 commit comments

Comments
 (0)