From 1d817879af9749bc4e3bd0f4f48dbf4d27958be2 Mon Sep 17 00:00:00 2001 From: Kevin Wooten Date: Wed, 5 Apr 2023 14:55:01 -0700 Subject: [PATCH] Validate maxLifetime & idleTimeout and document their zero values. --- .../src/main/java/io/vertx/sqlclient/PoolOptions.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vertx-sql-client/src/main/java/io/vertx/sqlclient/PoolOptions.java b/vertx-sql-client/src/main/java/io/vertx/sqlclient/PoolOptions.java index 055b03540..fe6add98f 100644 --- a/vertx-sql-client/src/main/java/io/vertx/sqlclient/PoolOptions.java +++ b/vertx-sql-client/src/main/java/io/vertx/sqlclient/PoolOptions.java @@ -188,12 +188,13 @@ public int getIdleTimeout() { } /** - * Establish an idle timeout for pooled connections. + * Establish an idle timeout for pooled connections, a value of zero disables the idle timeout. * * @param idleTimeout the pool connection idle timeout * @return a reference to this, so the API can be used fluently */ public PoolOptions setIdleTimeout(int idleTimeout) { + Arguments.require(idleTimeout >= 0, "idleTimeout must be >= 0"); this.idleTimeout = idleTimeout; return this; } @@ -224,12 +225,13 @@ public int getMaxLifetime() { } /** - * Establish a max lifetime for pooled connections. + * Establish a max lifetime for pooled connections, a value of zero disables the maximum lifetime. * * @param maxLifetime the pool connection max lifetime * @return a reference to this, so the API can be used fluently */ public PoolOptions setMaxLifetime(int maxLifetime) { + Arguments.require(maxLifetime >= 0, "maxLifetime must be >= 0"); this.maxLifetime = maxLifetime; return this; }