Skip to content

Commit

Permalink
Do NOT default maxPoolSize to minIdle when only minIdle is specified.
Browse files Browse the repository at this point in the history
  • Loading branch information
brettwooldridge committed Jan 28, 2019
1 parent cda2605 commit 86612b4
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/main/java/com/zaxxer/hikari/HikariConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}
Expand All @@ -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);
Expand Down

0 comments on commit 86612b4

Please sign in to comment.