set empty property as null in config

pull/496/head
Nitin 9 years ago
parent 4cef6b8585
commit 9ae1a01aa5

@ -42,6 +42,8 @@ import com.codahale.metrics.health.HealthCheckRegistry;
import com.zaxxer.hikari.metrics.MetricsTrackerFactory;
import com.zaxxer.hikari.util.PropertyElf;
import static com.zaxxer.hikari.util.UtilityElf.nullOrNotEmpty;
public class HikariConfig implements HikariConfigMXBean
{
private static final Logger LOGGER = LoggerFactory.getLogger(HikariConfig.class);
@ -746,6 +748,16 @@ public class HikariConfig implements HikariConfigMXBean
{
validateNumerics();
// treat empty property as null
catalog = nullOrNotEmpty(catalog);
connectionInitSql = nullOrNotEmpty(connectionInitSql);
connectionTestQuery = nullOrNotEmpty(connectionTestQuery);
transactionIsolationName = nullOrNotEmpty(transactionIsolationName);
dataSourceClassName = nullOrNotEmpty(dataSourceClassName);
dataSourceJndiName = nullOrNotEmpty(dataSourceJndiName);
driverClassName = nullOrNotEmpty(driverClassName);
jdbcUrl = nullOrNotEmpty(jdbcUrl);
if (poolName == null) {
poolName = "HikariPool-" + POOL_NUMBER.getAndIncrement();
}

@ -6,7 +6,6 @@ import static com.zaxxer.hikari.pool.ProxyConnection.DIRTY_BIT_ISOLATION;
import static com.zaxxer.hikari.pool.ProxyConnection.DIRTY_BIT_NETTIMEOUT;
import static com.zaxxer.hikari.pool.ProxyConnection.DIRTY_BIT_READONLY;
import static com.zaxxer.hikari.util.UtilityElf.createInstance;
import static com.zaxxer.hikari.util.UtilityElf.nullOrNotEmpty;
import java.lang.management.ManagementFactory;
import java.sql.Connection;
@ -68,14 +67,14 @@ abstract class PoolBase
this.config = config;
this.networkTimeout = -1;
this.catalog = nullOrNotEmpty(config.getCatalog());
this.catalog = config.getCatalog();
this.isReadOnly = config.isReadOnly();
this.isAutoCommit = config.isAutoCommit();
this.transactionIsolation = UtilityElf.getTransactionIsolation(config.getTransactionIsolation());
this.isQueryTimeoutSupported = UNINITIALIZED;
this.isNetworkTimeoutSupported = UNINITIALIZED;
this.isUseJdbc4Validation = nullOrNotEmpty(config.getConnectionTestQuery()) == null;
this.isUseJdbc4Validation = config.getConnectionTestQuery() == null;
this.isIsolateInternalQueries = config.isIsolateInternalQueries();
this.poolName = config.getPoolName();

@ -124,14 +124,14 @@ public final class UtilityElf
*/
public static int getTransactionIsolation(final String transactionIsolationName)
{
if (nullOrNotEmpty(transactionIsolationName) != null) {
if (transactionIsolationName != null) {
try {
final String upperName = transactionIsolationName.trim().toUpperCase();
final String upperName = transactionIsolationName.toUpperCase();
if (upperName.startsWith("TRANSACTION_")) {
Field field = Connection.class.getField(upperName);
return field.getInt(null);
}
final int level = Integer.parseInt(transactionIsolationName.trim());
final int level = Integer.parseInt(transactionIsolationName);
switch (level) {
case Connection.TRANSACTION_READ_UNCOMMITTED:
case Connection.TRANSACTION_READ_COMMITTED:

Loading…
Cancel
Save