From dbe93209241f389ab0583c366395c714b325d81b Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Fri, 21 Aug 2015 22:58:17 +0900 Subject: [PATCH] Back-out deoptimization. Benchmark shows degradation, which makes sense because of a new conditional in close() -- the return value of closeOpenStatements() -- which is 'true' 99.999% of the time and therefore the conditional is merely overhead. --- .../zaxxer/hikari/proxy/ConnectionProxy.java | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/zaxxer/hikari/proxy/ConnectionProxy.java b/src/main/java/com/zaxxer/hikari/proxy/ConnectionProxy.java index 378fabb9..318ac02a 100644 --- a/src/main/java/com/zaxxer/hikari/proxy/ConnectionProxy.java +++ b/src/main/java/com/zaxxer/hikari/proxy/ConnectionProxy.java @@ -147,11 +147,10 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy return statement; } - private final boolean closeOpenStatements() + private final void closeOpenStatements() { final int size = openStatements.size(); if (size > 0) { - boolean success = true; for (int i = 0; i < size; i++) { try { final Statement statement = openStatements.get(i); @@ -161,14 +160,11 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy } catch (SQLException e) { checkException(e); - success &= !poolEntry.evict; } } openStatements.clear(); - return success; } - return true; } // ********************************************************************** @@ -183,23 +179,22 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy leakTask.cancel(); try { - if (closeOpenStatements()) { - if (isCommitStateDirty) { - lastAccess = clockSource.currentTime(); - - if (!poolEntry.isAutoCommit) { - delegate.rollback(); - LOGGER.debug("{} - Executed rollback on connection {} due to dirty commit state on close().", poolEntry.parentPool, delegate); - } - } + closeOpenStatements(); + if (isCommitStateDirty) { + lastAccess = clockSource.currentTime(); - if (isConnectionStateDirty) { - poolEntry.resetConnectionState(); - lastAccess = clockSource.currentTime(); + if (!poolEntry.isAutoCommit) { + delegate.rollback(); + LOGGER.debug("{} - Executed rollback on connection {} due to dirty commit state on close().", poolEntry.parentPool, delegate); } + } - delegate.clearWarnings(); + if (isConnectionStateDirty) { + poolEntry.resetConnectionState(); + lastAccess = clockSource.currentTime(); } + + delegate.clearWarnings(); } catch (SQLException e) { // when connections are aborted, exceptions are often thrown that should not reach the application