diff --git a/src/main/java/com/zaxxer/hikari/HikariConfig.java b/src/main/java/com/zaxxer/hikari/HikariConfig.java index 613b4a96a..8e46953b5 100644 --- a/src/main/java/com/zaxxer/hikari/HikariConfig.java +++ b/src/main/java/com/zaxxer/hikari/HikariConfig.java @@ -746,7 +746,6 @@ public void setReadOnly(boolean readOnly) * * @return {@code true} if HikariCP will register MXBeans, {@code false} if it will not */ - @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean isRegisterMbeans() { return isRegisterMbeans; @@ -973,16 +972,6 @@ private void validateNumerics() maxLifetime = MAX_LIFETIME; } - if (idleTimeout + SECONDS.toMillis(1) > maxLifetime && maxLifetime > 0 && minIdle < maxPoolSize) { - LOGGER.warn("{} - idleTimeout is close to or more than maxLifetime, disabling it.", poolName); - idleTimeout = 0; - } - - if (idleTimeout != 0 && idleTimeout < SECONDS.toMillis(10)) { - LOGGER.warn("{} - idleTimeout is less than 10000ms, setting to default {}ms.", poolName, IDLE_TIMEOUT); - idleTimeout = IDLE_TIMEOUT; - } - if (leakDetectionThreshold > 0 && !unitTest) { if (leakDetectionThreshold < SECONDS.toMillis(2) || (leakDetectionThreshold > maxLifetime && maxLifetime > 0)) { LOGGER.warn("{} - leakDetectionThreshold is less than 2000ms or more than maxLifetime, disabling it.", poolName); @@ -1001,14 +990,22 @@ private void validateNumerics() } if (maxPoolSize < 1) { - maxPoolSize = (minIdle <= 0) ? DEFAULT_POOL_SIZE : minIdle; + maxPoolSize = DEFAULT_POOL_SIZE; } if (minIdle < 0 || minIdle > maxPoolSize) { minIdle = maxPoolSize; } - if (idleTimeout != IDLE_TIMEOUT && idleTimeout != 0 && minIdle == maxPoolSize) { + if (idleTimeout + SECONDS.toMillis(1) > maxLifetime && maxLifetime > 0 && minIdle < maxPoolSize) { + LOGGER.warn("{} - idleTimeout is close to or more than maxLifetime, disabling it.", poolName); + idleTimeout = 0; + } + else if (idleTimeout != 0 && idleTimeout < SECONDS.toMillis(10) && minIdle < maxPoolSize) { + LOGGER.warn("{} - idleTimeout is less than 10000ms, setting to default {}ms.", poolName, IDLE_TIMEOUT); + idleTimeout = IDLE_TIMEOUT; + } + else if (idleTimeout != IDLE_TIMEOUT && idleTimeout != 0 && minIdle == maxPoolSize) { LOGGER.warn("{} - idleTimeout has been set but has no effect because the pool is operating as a fixed size pool.", poolName); } } @@ -1018,7 +1015,6 @@ private void checkIfSealed() if (sealed) throw new IllegalStateException("The configuration of the pool is sealed once started. Use HikariConfigMXBean for runtime changes."); } - @SuppressWarnings("StatementWithEmptyBody") private void logConfiguration() { LOGGER.debug("{} - configuration:", poolName);