Minor performance tweaks and readability changes.

pull/192/head
Brett Wooldridge 10 years ago
parent 00b77f9cd3
commit c04f59f3b8

@ -46,8 +46,8 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
private final HikariPool parentPool; private final HikariPool parentPool;
private final PoolBagEntry bagEntry; private final PoolBagEntry bagEntry;
private final FastList<Statement> openStatements;
private final LeakTask leakTask; private final LeakTask leakTask;
private FastList<Statement> openStatements;
private boolean forceClose; private boolean forceClose;
private boolean isAnythingDirty; private boolean isAnythingDirty;
@ -187,21 +187,19 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
leakTask.cancel(); leakTask.cancel();
try { final int size = openStatements.size();
final int size = openStatements.size(); if (size > 0) {
if (size > 0) { for (int i = 0; i < size; i++) {
for (int i = 0; i < size; i++) { try {
try { openStatements.get(i).close();
openStatements.get(i).close(); }
} catch (SQLException e) {
catch (SQLException e) { checkException(e);
checkException(e);
}
} }
openStatements.clear();
} }
}
try {
if (isAnythingDirty) { if (isAnythingDirty) {
resetConnectionState(); resetConnectionState();
} }
@ -240,11 +238,11 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException public final Statement createStatement(int resultSetType, int concurrency) throws SQLException
{ {
checkClosed(); checkClosed();
try { try {
Statement proxyStatement = ProxyFactory.getProxyStatement(this, delegate.createStatement(resultSetType, resultSetConcurrency)); Statement proxyStatement = ProxyFactory.getProxyStatement(this, delegate.createStatement(resultSetType, concurrency));
return trackStatement(proxyStatement); return trackStatement(proxyStatement);
} }
catch (SQLException e) { catch (SQLException e) {
@ -254,11 +252,11 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException public final Statement createStatement(int resultSetType, int concurrency, int holdability) throws SQLException
{ {
checkClosed(); checkClosed();
try { try {
Statement proxyStatement = ProxyFactory.getProxyStatement(this, delegate.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability)); Statement proxyStatement = ProxyFactory.getProxyStatement(this, delegate.createStatement(resultSetType, concurrency, holdability));
return trackStatement(proxyStatement); return trackStatement(proxyStatement);
} }
catch (SQLException e) { catch (SQLException e) {
@ -272,8 +270,8 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
{ {
checkClosed(); checkClosed();
try { try {
CallableStatement proxyCallableStatement = ProxyFactory.getProxyCallableStatement(this, delegate.prepareCall(sql)); CallableStatement pcs = ProxyFactory.getProxyCallableStatement(this, delegate.prepareCall(sql));
return trackStatement(proxyCallableStatement); return trackStatement(pcs);
} }
catch (SQLException e) { catch (SQLException e) {
throw checkException(e); throw checkException(e);
@ -282,12 +280,12 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException public final CallableStatement prepareCall(String sql, int resultSetType, int concurrency) throws SQLException
{ {
checkClosed(); checkClosed();
try { try {
CallableStatement proxyCallableStatement = ProxyFactory.getProxyCallableStatement(this, delegate.prepareCall(sql, resultSetType, resultSetConcurrency)); CallableStatement pcs = ProxyFactory.getProxyCallableStatement(this, delegate.prepareCall(sql, resultSetType, concurrency));
return trackStatement(proxyCallableStatement); return trackStatement(pcs);
} }
catch (SQLException e) { catch (SQLException e) {
throw checkException(e); throw checkException(e);
@ -296,13 +294,12 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException public final CallableStatement prepareCall(String sql, int resultSetType, int concurrency, int holdability) throws SQLException
{ {
checkClosed(); checkClosed();
try { try {
CallableStatement proxyCallableStatement = ProxyFactory.getProxyCallableStatement(this, delegate.prepareCall(sql, resultSetType, resultSetConcurrency, CallableStatement pcs = ProxyFactory.getProxyCallableStatement(this, delegate.prepareCall(sql, resultSetType, concurrency, holdability));
resultSetHoldability)); return trackStatement(pcs);
return trackStatement(proxyCallableStatement);
} }
catch (SQLException e) { catch (SQLException e) {
throw checkException(e); throw checkException(e);
@ -339,12 +336,11 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException public final PreparedStatement prepareStatement(String sql, int resultSetType, int concurrency) throws SQLException
{ {
checkClosed(); checkClosed();
try { try {
PreparedStatement proxyPreparedStatement = ProxyFactory.getProxyPreparedStatement(this, PreparedStatement proxyPreparedStatement = ProxyFactory.getProxyPreparedStatement(this, delegate.prepareStatement(sql, resultSetType, concurrency));
delegate.prepareStatement(sql, resultSetType, resultSetConcurrency));
return trackStatement(proxyPreparedStatement); return trackStatement(proxyPreparedStatement);
} }
catch (SQLException e) { catch (SQLException e) {
@ -354,13 +350,11 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException public final PreparedStatement prepareStatement(String sql, int resultSetType, int concurrency, int holdability) throws SQLException
{ {
checkClosed(); checkClosed();
try { try {
PreparedStatement proxyPreparedStatement = ProxyFactory.getProxyPreparedStatement(this, delegate.prepareStatement(sql, resultSetType, PreparedStatement proxyPreparedStatement = ProxyFactory.getProxyPreparedStatement(this, delegate.prepareStatement(sql, resultSetType, concurrency, holdability));
resultSetConcurrency,
resultSetHoldability));
return trackStatement(proxyPreparedStatement); return trackStatement(proxyPreparedStatement);
} }
catch (SQLException e) { catch (SQLException e) {

@ -46,8 +46,8 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
private final HikariPool parentPool; private final HikariPool parentPool;
private final PoolBagEntry bagEntry; private final PoolBagEntry bagEntry;
private final FastList<Statement> openStatements;
private final LeakTask leakTask; private final LeakTask leakTask;
private FastList<Statement> openStatements;
private boolean forceClose; private boolean forceClose;
private boolean isAnythingDirty; private boolean isAnythingDirty;
@ -187,21 +187,19 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
leakTask.cancel(); leakTask.cancel();
try { final int size = openStatements.size();
final int size = openStatements.size(); if (size > 0) {
if (size > 0) { for (int i = 0; i < size; i++) {
for (int i = 0; i < size; i++) { try {
try { openStatements.get(i).close();
openStatements.get(i).close(); }
} catch (SQLException e) {
catch (SQLException e) { checkException(e);
checkException(e);
}
} }
openStatements.clear();
} }
}
try {
if (isAnythingDirty) { if (isAnythingDirty) {
resetConnectionState(); resetConnectionState();
} }
@ -240,11 +238,11 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException public final Statement createStatement(int resultSetType, int concurrency) throws SQLException
{ {
checkClosed(); checkClosed();
try { try {
Statement proxyStatement = ProxyFactory.getProxyStatement(this, delegate.createStatement(resultSetType, resultSetConcurrency)); Statement proxyStatement = ProxyFactory.getProxyStatement(this, delegate.createStatement(resultSetType, concurrency));
return trackStatement(proxyStatement); return trackStatement(proxyStatement);
} }
catch (SQLException e) { catch (SQLException e) {
@ -254,11 +252,11 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException public final Statement createStatement(int resultSetType, int concurrency, int holdability) throws SQLException
{ {
checkClosed(); checkClosed();
try { try {
Statement proxyStatement = ProxyFactory.getProxyStatement(this, delegate.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability)); Statement proxyStatement = ProxyFactory.getProxyStatement(this, delegate.createStatement(resultSetType, concurrency, holdability));
return trackStatement(proxyStatement); return trackStatement(proxyStatement);
} }
catch (SQLException e) { catch (SQLException e) {
@ -272,8 +270,8 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
{ {
checkClosed(); checkClosed();
try { try {
CallableStatement proxyCallableStatement = ProxyFactory.getProxyCallableStatement(this, delegate.prepareCall(sql)); CallableStatement pcs = ProxyFactory.getProxyCallableStatement(this, delegate.prepareCall(sql));
return trackStatement(proxyCallableStatement); return trackStatement(pcs);
} }
catch (SQLException e) { catch (SQLException e) {
throw checkException(e); throw checkException(e);
@ -282,12 +280,12 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException public final CallableStatement prepareCall(String sql, int resultSetType, int concurrency) throws SQLException
{ {
checkClosed(); checkClosed();
try { try {
CallableStatement proxyCallableStatement = ProxyFactory.getProxyCallableStatement(this, delegate.prepareCall(sql, resultSetType, resultSetConcurrency)); CallableStatement pcs = ProxyFactory.getProxyCallableStatement(this, delegate.prepareCall(sql, resultSetType, concurrency));
return trackStatement(proxyCallableStatement); return trackStatement(pcs);
} }
catch (SQLException e) { catch (SQLException e) {
throw checkException(e); throw checkException(e);
@ -296,13 +294,12 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException public final CallableStatement prepareCall(String sql, int resultSetType, int concurrency, int holdability) throws SQLException
{ {
checkClosed(); checkClosed();
try { try {
CallableStatement proxyCallableStatement = ProxyFactory.getProxyCallableStatement(this, delegate.prepareCall(sql, resultSetType, resultSetConcurrency, CallableStatement pcs = ProxyFactory.getProxyCallableStatement(this, delegate.prepareCall(sql, resultSetType, concurrency, holdability));
resultSetHoldability)); return trackStatement(pcs);
return trackStatement(proxyCallableStatement);
} }
catch (SQLException e) { catch (SQLException e) {
throw checkException(e); throw checkException(e);
@ -339,12 +336,11 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException public final PreparedStatement prepareStatement(String sql, int resultSetType, int concurrency) throws SQLException
{ {
checkClosed(); checkClosed();
try { try {
PreparedStatement proxyPreparedStatement = ProxyFactory.getProxyPreparedStatement(this, PreparedStatement proxyPreparedStatement = ProxyFactory.getProxyPreparedStatement(this, delegate.prepareStatement(sql, resultSetType, concurrency));
delegate.prepareStatement(sql, resultSetType, resultSetConcurrency));
return trackStatement(proxyPreparedStatement); return trackStatement(proxyPreparedStatement);
} }
catch (SQLException e) { catch (SQLException e) {
@ -354,13 +350,11 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException public final PreparedStatement prepareStatement(String sql, int resultSetType, int concurrency, int holdability) throws SQLException
{ {
checkClosed(); checkClosed();
try { try {
PreparedStatement proxyPreparedStatement = ProxyFactory.getProxyPreparedStatement(this, delegate.prepareStatement(sql, resultSetType, PreparedStatement proxyPreparedStatement = ProxyFactory.getProxyPreparedStatement(this, delegate.prepareStatement(sql, resultSetType, concurrency, holdability));
resultSetConcurrency,
resultSetHoldability));
return trackStatement(proxyPreparedStatement); return trackStatement(proxyPreparedStatement);
} }
catch (SQLException e) { catch (SQLException e) {

Loading…
Cancel
Save