Skip to content

Commit

Permalink
Fixes #465 fix apparent leak of one connection leak at startup when m…
Browse files Browse the repository at this point in the history
…inimumIdle=0 ... the connection is not leaked, but the ProxyLeakTask was not cancelled.
  • Loading branch information
brettwooldridge committed Oct 21, 2015
1 parent 755f2da commit 37b96f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
9 changes: 6 additions & 3 deletions src/main/java/com/zaxxer/hikari/pool/HikariPool.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -252,11 +252,14 @@ public final synchronized void shutdown() throws InterruptedException
/** /**
* Evict a connection from the pool. * Evict a connection from the pool.
* *
* @param proxyConnection the connection to evict * @param connection the connection to evict
*/ */
public final void evictConnection(Connection proxyConnection) public final void evictConnection(Connection connection)
{ {
softEvictConnection(((ProxyConnection) proxyConnection).getPoolEntry(), "(connection evicted by user)", true /* owner */); ProxyConnection proxyConnection = (ProxyConnection) connection;
proxyConnection.cancelLeakTask();

softEvictConnection(proxyConnection.getPoolEntry(), "(connection evicted by user)", true /* owner */);
} }


public void setMetricRegistry(Object metricRegistry) public void setMetricRegistry(Object metricRegistry)
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/zaxxer/hikari/pool/ProxyConnection.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -133,16 +133,14 @@ final int getNetworkTimeoutState()
} }


// *********************************************************************** // ***********************************************************************
// IHikariConnectionProxy methods // Internal methods
// *********************************************************************** // ***********************************************************************


/** {@inheritDoc} */
final PoolEntry getPoolEntry() final PoolEntry getPoolEntry()
{ {
return poolEntry; return poolEntry;
} }


/** {@inheritDoc} */
final SQLException checkException(final SQLException sqle) final SQLException checkException(final SQLException sqle)
{ {
final String sqlState = sqle.getSQLState(); final String sqlState = sqle.getSQLState();
Expand All @@ -165,13 +163,11 @@ final SQLException checkException(final SQLException sqle)
return sqle; return sqle;
} }


/** {@inheritDoc} */
final void untrackStatement(final Statement statement) final void untrackStatement(final Statement statement)
{ {
openStatements.remove(statement); openStatements.remove(statement);
} }


/** {@inheritDoc} */
final void markCommitStateDirty() final void markCommitStateDirty()
{ {
if (isAutoCommit) { if (isAutoCommit) {
Expand All @@ -182,9 +178,13 @@ final void markCommitStateDirty()
} }
} }


// *********************************************************************** /**
// Internal methods *
// *********************************************************************** */
void cancelLeakTask()
{
leakTask.cancel();
}


private final <T extends Statement> T trackStatement(final T statement) private final <T extends Statement> T trackStatement(final T statement)
{ {
Expand Down

0 comments on commit 37b96f1

Please sign in to comment.