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.
pull/395/head
Brett Wooldridge 10 years ago
parent 182c8c58ab
commit dbe9320924

@ -147,11 +147,10 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
return statement; return statement;
} }
private final boolean closeOpenStatements() private final void closeOpenStatements()
{ {
final int size = openStatements.size(); final int size = openStatements.size();
if (size > 0) { if (size > 0) {
boolean success = true;
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
try { try {
final Statement statement = openStatements.get(i); final Statement statement = openStatements.get(i);
@ -161,14 +160,11 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
} }
catch (SQLException e) { catch (SQLException e) {
checkException(e); checkException(e);
success &= !poolEntry.evict;
} }
} }
openStatements.clear(); openStatements.clear();
return success;
} }
return true;
} }
// ********************************************************************** // **********************************************************************
@ -183,23 +179,22 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
leakTask.cancel(); leakTask.cancel();
try { try {
if (closeOpenStatements()) { closeOpenStatements();
if (isCommitStateDirty) { if (isCommitStateDirty) {
lastAccess = clockSource.currentTime(); lastAccess = clockSource.currentTime();
if (!poolEntry.isAutoCommit) {
delegate.rollback();
LOGGER.debug("{} - Executed rollback on connection {} due to dirty commit state on close().", poolEntry.parentPool, delegate);
}
}
if (isConnectionStateDirty) { if (!poolEntry.isAutoCommit) {
poolEntry.resetConnectionState(); delegate.rollback();
lastAccess = clockSource.currentTime(); 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) { catch (SQLException e) {
// when connections are aborted, exceptions are often thrown that should not reach the application // when connections are aborted, exceptions are often thrown that should not reach the application

Loading…
Cancel
Save