better fix

pull/347/head
Nitin 10 years ago
parent 07ca37e7a4
commit dc5b484f52

@ -474,6 +474,7 @@ public class HikariConfig implements HikariConfigMXBean
* @param metricRegistry the Codahale MetricRegistry to set * @param metricRegistry the Codahale MetricRegistry to set
*/ */
public void setMetricRegistry(Object metricRegistry) public void setMetricRegistry(Object metricRegistry)
{
if (metricsTrackerFactory != null) { if (metricsTrackerFactory != null) {
throw new IllegalStateException("cannot use setMetricRegistry() and setMetricsTrackerFactory() together"); throw new IllegalStateException("cannot use setMetricRegistry() and setMetricsTrackerFactory() together");
} }

@ -109,23 +109,24 @@ public final class PoolElf
{ {
if (transactionIsolationName != null) { if (transactionIsolationName != null) {
try { try {
int level = Integer.parseInt(transactionIsolationName); String upperName = transactionIsolationName.toUpperCase();
//its number if (upperName.startsWith("TRANSACTION_")) {
switch (level) { Field field = Connection.class.getField(transactionIsolationName);
case Connection.TRANSACTION_READ_UNCOMMITTED: return field.getInt(null);
case Connection.TRANSACTION_READ_COMMITTED: }
case Connection.TRANSACTION_REPEATABLE_READ: else {
case Connection.TRANSACTION_SERIALIZABLE: int level = Integer.parseInt(transactionIsolationName);
return level; //its number
} switch (level) {
throw new IllegalArgumentException("Invalid transaction isolation value: " + transactionIsolationName); case Connection.TRANSACTION_READ_UNCOMMITTED:
} case Connection.TRANSACTION_READ_COMMITTED:
catch (Exception e) { case Connection.TRANSACTION_REPEATABLE_READ:
//its name case Connection.TRANSACTION_SERIALIZABLE:
} return level;
try { }
Field field = Connection.class.getField(transactionIsolationName); //invalid level
return field.getInt(null); throw new IllegalArgumentException();
}
} }
catch (Exception e) { catch (Exception e) {
throw new IllegalArgumentException("Invalid transaction isolation value: " + transactionIsolationName); throw new IllegalArgumentException("Invalid transaction isolation value: " + transactionIsolationName);

Loading…
Cancel
Save