pull/571/head
Nitin 9 years ago
parent 82f7c15ace
commit 2b6da07d26

@ -234,15 +234,19 @@ public class HikariConfig implements HikariConfigMXBean
@Override
public void setConnectionTimeout(long connectionTimeoutMs)
{
if (connectionTimeoutMs == 0L) {
if (connectionTimeoutMs == 0) {
this.connectionTimeout = Integer.MAX_VALUE;
}
else if (connectionTimeoutMs < 250L) {
else if (connectionTimeoutMs < 250) {
throw new IllegalArgumentException("connectionTimeout cannot be less than 250ms");
}
else {
this.connectionTimeout = connectionTimeoutMs;
}
if (validationTimeout > connectionTimeoutMs) {
this.validationTimeout = connectionTimeoutMs;
}
}
/** {@inheritDoc} */
@ -256,12 +260,16 @@ public class HikariConfig implements HikariConfigMXBean
@Override
public void setValidationTimeout(long validationTimeoutMs)
{
if (validationTimeoutMs < 250L) {
if (validationTimeoutMs < 250) {
throw new IllegalArgumentException("validationTimeout cannot be less than 250ms");
}
else {
this.validationTimeout = validationTimeoutMs;
}
if (validationTimeout > connectionTimeout) {
this.validationTimeout = connectionTimeout;
}
}
/**
@ -334,7 +342,7 @@ public class HikariConfig implements HikariConfigMXBean
this.driverClassName = driverClassName;
}
catch (Exception e) {
throw new RuntimeException("Could not load class of driverClassName " + driverClassName, e);
throw new RuntimeException("Failed to load class of driverClassName " + driverClassName, e);
}
}
@ -836,13 +844,13 @@ public class HikariConfig implements HikariConfigMXBean
}
}
if (validationTimeout < 250L) {
if (validationTimeout < 250) {
LOGGER.warn("{} - validationTimeout is less than 250ms, setting to {}ms.", poolName, VALIDATION_TIMEOUT);
validationTimeout = VALIDATION_TIMEOUT;
}
if (connectionTimeout != Integer.MAX_VALUE) {
if (connectionTimeout < 250L) {
if (connectionTimeout < 250) {
LOGGER.warn("{} - connectionTimeout is less than 250ms, setting to {}ms.", poolName, CONNECTION_TIMEOUT);
connectionTimeout = CONNECTION_TIMEOUT;
}
@ -905,11 +913,11 @@ public class HikariConfig implements HikariConfigMXBean
PropertyElf.setTargetFromProperties(this, props);
}
else {
throw new IllegalArgumentException("Property file " + propertyFileName + " was not found.");
throw new IllegalArgumentException("Cannot find property file: " + propertyFileName);
}
}
catch (IOException io) {
throw new RuntimeException("Error loading properties file", io);
throw new RuntimeException("Failed to read property file", io);
}
}
@ -922,7 +930,7 @@ public class HikariConfig implements HikariConfigMXBean
field.set(other, field.get(this));
}
catch (Exception e) {
throw new RuntimeException("Exception copying HikariConfig state: " + e.getMessage(), e);
throw new RuntimeException("Failed to copy HikariConfig state: " + e.getMessage(), e);
}
}
}

@ -171,7 +171,7 @@ public final class PropertyElf
}
}
catch (Exception e) {
LOGGER.error("Exception setting property {} on target {}", propName, target.getClass(), e);
LOGGER.error("Failed to set property {} on target {}", propName, target.getClass(), e);
throw new RuntimeException(e);
}
}

@ -46,7 +46,7 @@ public class TestValidation
config.validate();
}
catch (IllegalArgumentException ise) {
Assert.assertTrue(ise.getMessage().contains("Property file"));
Assert.assertTrue(ise.getMessage().contains("property file"));
}
}

Loading…
Cancel
Save