Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
brettwooldridge committed Mar 30, 2014
2 parents 9c058e7 + ec37375 commit e3e913c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/zaxxer/hikari/HikariMBeanElf.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static void unregisterMBeans(HikariConfig configuration, HikariPool pool)
}
else
{
LOGGER.error("No registered MBean for {0}.", configuration.getPoolName());
LOGGER.error("No registered MBean for {}.", configuration.getPoolName());
}
}
catch (Exception e)
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/com/zaxxer/hikari/HikariPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
public class MetricsTracker
{
private static final Context NO_CONTEXT = new Context();
protected static final Context NO_CONTEXT = new Context();

public static class Context
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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);
}
}

/**
Expand Down

0 comments on commit e3e913c

Please sign in to comment.