From 96c91d549a27d50c4983dae55dd592820dd65afb Mon Sep 17 00:00:00 2001 From: Nitin Date: Fri, 29 Jan 2016 13:07:45 +0530 Subject: [PATCH] disable leakDetectionThreshold if not valid. --- .../java/com/zaxxer/hikari/HikariConfig.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/zaxxer/hikari/HikariConfig.java b/src/main/java/com/zaxxer/hikari/HikariConfig.java index d0f4fcda..2ba45b1d 100644 --- a/src/main/java/com/zaxxer/hikari/HikariConfig.java +++ b/src/main/java/com/zaxxer/hikari/HikariConfig.java @@ -828,7 +828,7 @@ public class HikariConfig implements HikariConfigMXBean } if (idleTimeout + TimeUnit.SECONDS.toMillis(1) > maxLifetime && maxLifetime > 0) { - LOGGER.warn("idleTimeout is close to or greater than maxLifetime, disabling it."); + LOGGER.warn("idleTimeout is close to or more than maxLifetime, disabling it."); idleTimeout = 0; } @@ -837,26 +837,24 @@ public class HikariConfig implements HikariConfigMXBean idleTimeout = IDLE_TIMEOUT; } + if (leakDetectionThreshold > 0 && !unitTest) { + if (leakDetectionThreshold < TimeUnit.SECONDS.toMillis(2) || (leakDetectionThreshold > maxLifetime && maxLifetime > 0)) { + LOGGER.warn("leakDetectionThreshold is less than 2000ms or more than maxLifetime, disabling it."); + leakDetectionThreshold = 0L; + } + } + if (connectionTimeout != Integer.MAX_VALUE) { if (validationTimeout > connectionTimeout) { LOGGER.warn("validationTimeout should be less than connectionTimeout, setting validationTimeout to connectionTimeout"); validationTimeout = connectionTimeout; } if (maxLifetime > 0 && connectionTimeout > maxLifetime) { - LOGGER.warn("connectionTimeout should be less than maxLifetime, setting maxLifetime to connectionTimeout"); - maxLifetime = connectionTimeout; + LOGGER.warn("connectionTimeout should be less than maxLifetime, setting connectionTimeout to maxLifetime"); + connectionTimeout = maxLifetime; } } - if (leakDetectionThreshold != 0 && leakDetectionThreshold < TimeUnit.SECONDS.toMillis(2) && !unitTest) { - LOGGER.warn("leakDetectionThreshold is less than 2000ms, setting to minimum 2000ms."); - leakDetectionThreshold = 2000L; - } - else if (leakDetectionThreshold > maxLifetime && maxLifetime > 2000) { - LOGGER.warn("leakDetectionThreshold is more than maxLifetime, setting to minimum 2000ms."); - leakDetectionThreshold = 2000L; - } - if (maxPoolSize < 0) { if (minIdle < 0) { minIdle = 10;