Code cleanup.

pull/140/head
Brett Wooldridge 11 years ago
parent 00fb00bb56
commit 365908a42e

@ -139,10 +139,14 @@ public class HikariConfig implements HikariConfigMBean
try { try {
final InputStream is = propFile.isFile() ? new FileInputStream(propFile) : this.getClass().getResourceAsStream(propertyFileName); final InputStream is = propFile.isFile() ? new FileInputStream(propFile) : this.getClass().getResourceAsStream(propertyFileName);
if (is != null) { if (is != null) {
Properties props = new Properties(); try {
props.load(is); Properties props = new Properties();
is.close(); props.load(is);
PropertyBeanSetter.setTargetFromProperties(this, props); PropertyBeanSetter.setTargetFromProperties(this, props);
}
finally {
is.close();
}
} }
else { else {
throw new IllegalArgumentException("Property file " + propertyFileName + " was not found."); throw new IllegalArgumentException("Property file " + propertyFileName + " was not found.");
@ -725,7 +729,7 @@ public class HikariConfig implements HikariConfigMBean
minIdle = maxPoolSize; minIdle = maxPoolSize;
} }
if (idleTimeout < TimeUnit.SECONDS.toMillis(30) && idleTimeout != 0) { if (idleTimeout != 0 && idleTimeout < TimeUnit.SECONDS.toMillis(30)) {
logger.warn("idleTimeout is less than 30000ms, did you specify the wrong time unit? Using default instead"); logger.warn("idleTimeout is less than 30000ms, did you specify the wrong time unit? Using default instead");
idleTimeout = IDLE_TIMEOUT; idleTimeout = IDLE_TIMEOUT;
} }
@ -739,7 +743,7 @@ public class HikariConfig implements HikariConfigMBean
logger.error("maxLifetime cannot be negative."); logger.error("maxLifetime cannot be negative.");
throw new IllegalArgumentException("maxLifetime cannot be negative."); throw new IllegalArgumentException("maxLifetime cannot be negative.");
} }
else if (maxLifetime < TimeUnit.SECONDS.toMillis(120) && maxLifetime != 0) { else if (maxLifetime != 0 && maxLifetime < TimeUnit.SECONDS.toMillis(120)) {
logger.warn("maxLifetime is less than 120000ms, did you specify the wrong time unit? Using default instead."); logger.warn("maxLifetime is less than 120000ms, did you specify the wrong time unit? Using default instead.");
maxLifetime = MAX_LIFETIME; maxLifetime = MAX_LIFETIME;
} }

@ -723,7 +723,7 @@ public class HikariConfig implements HikariConfigMBean
minIdle = maxPoolSize; minIdle = maxPoolSize;
} }
if (idleTimeout < TimeUnit.SECONDS.toMillis(30) && idleTimeout != 0) { if (idleTimeout != 0 && idleTimeout < TimeUnit.SECONDS.toMillis(30)) {
logger.warn("idleTimeout is less than 30000ms, did you specify the wrong time unit? Using default instead"); logger.warn("idleTimeout is less than 30000ms, did you specify the wrong time unit? Using default instead");
idleTimeout = IDLE_TIMEOUT; idleTimeout = IDLE_TIMEOUT;
} }
@ -737,7 +737,7 @@ public class HikariConfig implements HikariConfigMBean
logger.error("maxLifetime cannot be negative."); logger.error("maxLifetime cannot be negative.");
throw new IllegalArgumentException("maxLifetime cannot be negative."); throw new IllegalArgumentException("maxLifetime cannot be negative.");
} }
else if (maxLifetime < TimeUnit.SECONDS.toMillis(120) && maxLifetime != 0) { else if (maxLifetime != 0 && maxLifetime < TimeUnit.SECONDS.toMillis(120)) {
logger.warn("maxLifetime is less than 120000ms, did you specify the wrong time unit? Using default instead."); logger.warn("maxLifetime is less than 120000ms, did you specify the wrong time unit? Using default instead.");
maxLifetime = MAX_LIFETIME; maxLifetime = MAX_LIFETIME;
} }

Loading…
Cancel
Save