Merge branch 'dev'

* dev:
  Updated change log
  Restore max lifetime check to getConnection() rather than only in the housekeeper thread.  An extremely active pool may never find an idle connection in the housekeeper alone.
  Restore max lifetime check to getConnection() rather than only in the housekeeper thread.  An extremely active pool may never find an idle connection in the housekeeper alone.
  Fixed #51 fix logging string substitution parameter.
  Switch back to setting our own context class loader during code generation.
  Change visibility.
pull/60/head
Brett Wooldridge 11 years ago
commit e3e913c8cf

@ -1,5 +1,11 @@
HikariCP Changes
Changes between 1.3.4 and 1.3.5
*) Fixed a regression in the Javassist code generation.
*) Various bug fixes and minor enhancements.
Changes between 1.3.3 and 1.3.4
*) Added new property isolateInternalQueries used to control whether

@ -89,7 +89,7 @@ public final class HikariMBeanElf
}
else
{
LOGGER.error("No registered MBean for {0}.", configuration.getPoolName());
LOGGER.error("No registered MBean for {}.", configuration.getPoolName());
}
}
catch (Exception e)

@ -138,32 +138,34 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
Connection getConnection() throws SQLException
{
final long start = System.currentTimeMillis();
final long maxLife = configuration.getMaxLifetime();
final Context context = metricsTracker.recordConnectionRequest(start);
long timeout = configuration.getConnectionTimeout();
try
{
do
{
IHikariConnectionProxy connectionProxy = connectionBag.borrow(timeout, TimeUnit.MILLISECONDS);
if (connectionProxy == null) // We timed out... break and throw exception
IHikariConnectionProxy connection = connectionBag.borrow(timeout, TimeUnit.MILLISECONDS);
if (connection == null) // We timed out... break and throw exception
{
break;
}
connectionProxy.unclose();
connection.unclose();
if (System.currentTimeMillis() - connectionProxy.getLastAccess() > 1000 && !isConnectionAlive(connectionProxy, timeout))
final long now = System.currentTimeMillis();
if ((maxLife > 0 && now - connection.getCreationTime() > maxLife) || (now - connection.getLastAccess() > 1000 && !isConnectionAlive(connection, timeout)))
{
closeConnection(connectionProxy); // Throw away the dead connection, try again
closeConnection(connection); // Throw away the dead connection, try again
timeout -= (System.currentTimeMillis() - start);
continue;
}
else if (leakDetectionThreshold > 0)
{
connectionProxy.captureStack(leakDetectionThreshold, houseKeepingTimer);
connection.captureStack(leakDetectionThreshold, houseKeepingTimer);
}
return connectionProxy;
return connection;
}
while (timeout > 0);

@ -24,7 +24,7 @@ package com.zaxxer.hikari.metrics;
*/
public class MetricsTracker
{
private static final Context NO_CONTEXT = new Context();
protected static final Context NO_CONTEXT = new Context();
public static class Context
{

@ -49,8 +49,11 @@ public final class JavassistProxyFactory
static
{
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try
{
Thread.currentThread().setContextClassLoader(JavassistProxyFactory.class.getClassLoader());
JavassistProxyFactory proxyFactoryFactory = new JavassistProxyFactory();
proxyFactoryFactory.modifyProxyFactory();
}
@ -59,6 +62,10 @@ public final class JavassistProxyFactory
LoggerFactory.getLogger(JavassistProxyFactory.class).error("Fatal exception during proxy generation", e);
throw new RuntimeException(e);
}
finally
{
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
/**

Loading…
Cancel
Save