Merge branch '2.3.x' of github.com-brettwooldridge:brettwooldridge/HikariCP into 2.3.x

# By Brett Wooldridge (1) and johnon (1)
* '2.3.x' of github.com-brettwooldridge:brettwooldridge/HikariCP:
  Fix #269 Guard against drivers that construct an SQLException where the 'cause' is self-referential.  Hopefully the cycle is not multi-layers deep, because this check will only guard against one "loop".
  Allows Hikari to look up an arbitary JNDI resource name for the metric registry
pull/274/head
Brett Wooldridge 10 years ago
commit 6833c25ab6

@ -26,7 +26,6 @@ import java.util.TreeSet;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
@ -505,8 +504,7 @@ public abstract class AbstractHikariConfig implements HikariConfigMBean
if (metricRegistry instanceof String) {
try {
InitialContext initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
metricRegistry = (MetricRegistry) envCtx.lookup((String) metricRegistry);
metricRegistry = (MetricRegistry) initCtx.lookup((String) metricRegistry);
}
catch (NamingException e) {
throw new IllegalArgumentException(e);
@ -542,8 +540,7 @@ public abstract class AbstractHikariConfig implements HikariConfigMBean
if (healthCheckRegistry instanceof String) {
try {
InitialContext initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
healthCheckRegistry = (MetricRegistry) envCtx.lookup((String) healthCheckRegistry);
healthCheckRegistry = (MetricRegistry) initCtx.lookup((String) healthCheckRegistry);
}
catch (NamingException e) {
throw new IllegalArgumentException(e);

@ -109,7 +109,7 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
LOGGER.warn(String.format("Connection %s (%s) marked as broken because of SQLSTATE(%s), ErrorCode(%d).", delegate.toString(),
parentPool.toString(), sqlState, sqle.getErrorCode()), sqle);
}
else if (sqle.getNextException() instanceof SQLException) {
else if (sqle.getNextException() instanceof SQLException && sqle != sqle.getNextException()) {
checkException(sqle.getNextException());
}
}

Loading…
Cancel
Save