More code size reduction for inlining.

pull/11/head
Brett Wooldridge 11 years ago
parent 8458db1ea7
commit e7ce627472

@ -388,7 +388,7 @@ public class HikariClassTransformer implements ClassFileTransformer
if ("java.sql.SQLException".equals(exception.getName())) // only add try..catch to methods throwing SQLException
{
LOGGER.debug("Injecting try..catch into {}{}", method.getName(), method.getSignature());
method.addCatch("throw _checkException($e);", exception);
method.addCatch("_checkException($e); throw $e;", exception);
break;
}
}

@ -60,7 +60,7 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
@HikariInject protected ThreadLocal<Boolean> _isClosed;
@HikariInject protected ArrayList<Statement> _openStatements;
@HikariInject protected ArrayList<IHikariStatementProxy> _openStatements;
@HikariInject protected HikariPool _parentPool;
@HikariInject protected boolean _forceClose;
@ -109,37 +109,37 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
}
@HikariInject
public long _getCreationTime()
public final long _getCreationTime()
{
return _creationTime;
}
@HikariInject
public long _getLastAccess()
public final long _getLastAccess()
{
return _lastAccess;
}
@HikariInject
public void _markLastAccess()
public final void _markLastAccess()
{
this._lastAccess = System.currentTimeMillis();
}
@HikariInject
public void _setParentPool(HikariPool parentPool)
public final void _setParentPool(HikariPool parentPool)
{
this._parentPool = parentPool;
}
@HikariInject
public void _unclose()
public final void _unclose()
{
_isClosed.set(false);
}
@HikariInject
public void _captureStack(long leakDetectionThreshold, Timer scheduler)
public final void _captureStack(long leakDetectionThreshold, Timer scheduler)
{
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
_stackTrace = new StackTraceElement[trace.length - 4];
@ -150,18 +150,19 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
}
@HikariInject
public boolean _isBrokenConnection()
public final boolean _isBrokenConnection()
{
return _forceClose;
}
@HikariInject
public SQLException _checkException(SQLException sqle)
public final void _checkException(SQLException sqle)
{
String sqlState = sqle.getSQLState();
_forceClose |= (sqlState != null && (sqlState.startsWith("08") || SQL_ERRORS.contains(sqlState)));
return sqle;
if (sqlState != null)
{
_forceClose |= sqlState.startsWith("08") | SQL_ERRORS.contains(sqlState);
}
}
@HikariInject
@ -169,19 +170,15 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
{
if (_openStatements == null)
{
_openStatements = new ArrayList<Statement>(64);
_openStatements = new ArrayList<IHikariStatementProxy>(64);
_creationTime = _lastAccess = System.currentTimeMillis();
}
if (_isClosed == null)
{
_isClosed = new ThreadLocal<>();
_isClosed.set(false);
}
}
@HikariInject
protected void _checkClosed() throws SQLException
protected final void _checkClosed() throws SQLException
{
if (_isClosed.get())
{
@ -190,12 +187,11 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
}
@HikariInject
protected <T extends Statement> T _trackStatement(T statement)
protected final <T extends IHikariStatementProxy> T _trackStatement(T statement)
{
IHikariStatementProxy statementProxy = (IHikariStatementProxy) statement;
if (statementProxy._getConnectionProxy() == null)
if (statement._getConnectionProxy() == null)
{
statementProxy._setConnectionProxy(this);
statement._setConnectionProxy(this);
_openStatements.add(statement);
}
@ -209,7 +205,7 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
@HikariOverride
public void close() throws SQLException
{
if (!_isClosed.get())
if (!isClosed())
{
_isClosed.set(true);
if (_leakTask != null)
@ -229,7 +225,8 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
}
catch (SQLException e)
{
throw _checkException(e);
_checkException(e);
throw e;
}
finally
{
@ -251,13 +248,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
_checkClosed();
try
{
Statement statement = __createStatement();
IHikariStatementProxy statement = (IHikariStatementProxy) __createStatement();
return _trackStatement(statement);
}
catch (SQLException e)
{
throw _checkException(e);
_checkException(e);
throw e;
}
}
@ -267,13 +265,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
_checkClosed();
try
{
Statement statement = __createStatement(resultSetType, resultSetConcurrency);
IHikariStatementProxy statement = (IHikariStatementProxy) __createStatement(resultSetType, resultSetConcurrency);
return _trackStatement(statement);
}
catch (SQLException e)
{
throw _checkException(e);
_checkException(e);
throw e;
}
}
@ -283,13 +282,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
_checkClosed();
try
{
Statement statement = __createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
IHikariStatementProxy statement = (IHikariStatementProxy) __createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
return _trackStatement(statement);
}
catch (SQLException e)
{
throw _checkException(e);
_checkException(e);
throw e;
}
}
@ -299,13 +299,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
_checkClosed();
try
{
CallableStatement statement = __prepareCall(sql);
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareCall(sql);
return _trackStatement(statement);
}
catch (SQLException e)
{
throw _checkException(e);
_checkException(e);
throw e;
}
}
@ -315,13 +316,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
_checkClosed();
try
{
CallableStatement statement = __prepareCall(sql, resultSetType, resultSetConcurrency);
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareCall(sql, resultSetType, resultSetConcurrency);
return _trackStatement(statement);
}
catch (SQLException e)
{
throw _checkException(e);
_checkException(e);
throw e;
}
}
@ -331,13 +333,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
_checkClosed();
try
{
CallableStatement statement = __prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
return _trackStatement(statement);
}
catch (SQLException e)
{
throw _checkException(e);
_checkException(e);
throw e;
}
}
@ -347,13 +350,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
_checkClosed();
try
{
PreparedStatement statement = __prepareStatement(sql);
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareStatement(sql);
return _trackStatement(statement);
}
catch (SQLException e)
{
throw _checkException(e);
_checkException(e);
throw e;
}
}
@ -363,13 +367,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
_checkClosed();
try
{
PreparedStatement statement = __prepareStatement(sql, autoGeneratedKeys);
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareStatement(sql, autoGeneratedKeys);
return _trackStatement(statement);
}
catch (SQLException e)
{
throw _checkException(e);
_checkException(e);
throw e;
}
}
@ -379,13 +384,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
_checkClosed();
try
{
PreparedStatement statement = __prepareStatement(sql, resultSetType, resultSetConcurrency);
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareStatement(sql, resultSetType, resultSetConcurrency);
return _trackStatement(statement);
}
catch (SQLException e)
{
throw _checkException(e);
_checkException(e);
throw e;
}
}
@ -395,13 +401,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
_checkClosed();
try
{
PreparedStatement statement = __prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
return _trackStatement(statement);
}
catch (SQLException e)
{
throw _checkException(e);
_checkException(e);
throw e;
}
}
@ -411,13 +418,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
_checkClosed();
try
{
PreparedStatement statement = __prepareStatement(sql, columnIndexes);
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareStatement(sql, columnIndexes);
return _trackStatement(statement);
}
catch (SQLException e)
{
throw _checkException(e);
_checkException(e);
throw e;
}
}
@ -427,13 +435,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
_checkClosed();
try
{
PreparedStatement statement = __prepareStatement(sql, columnNames);
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareStatement(sql, columnNames);
return _trackStatement(statement);
}
catch (SQLException e)
{
throw _checkException(e);
_checkException(e);
throw e;
}
}
@ -451,7 +460,8 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
}
catch (SQLException e)
{
throw _checkException(e);
_checkException(e);
throw e;
}
}

@ -34,7 +34,7 @@ public interface IHikariConnectionProxy
void _unregisterStatement(Object statement);
SQLException _checkException(SQLException sqle);
void _checkException(SQLException sqle);
boolean _isBrokenConnection();

@ -1,8 +1,9 @@
package com.zaxxer.hikari.proxy;
import java.sql.CallableStatement;
import java.sql.SQLException;
public interface IHikariStatementProxy
public interface IHikariStatementProxy extends CallableStatement
{
void close() throws SQLException;
@ -12,5 +13,5 @@ public interface IHikariStatementProxy
void _releaseResultSet(IHikariResultSetProxy resultSet);
SQLException _checkException(SQLException e);
void _checkException(SQLException e);
}

@ -72,9 +72,9 @@ public final class JavassistProxyFactoryFactory
try
{
String methodBody = "{ _checkClosed(); try { return ((cast) delegate).method($$); } catch (SQLException e) { throw _checkException(e); } }";
String methodBody = "{ _checkClosed(); try { return ((cast) delegate).method($$); } catch (SQLException e) { _checkException(e); throw e;} }";
generateProxyClass(Connection.class, ConnectionProxy.class, methodBody);
methodBody = "{ try { return ((cast) delegate).method($$); } catch (SQLException e) { throw _checkException(e); } }";
methodBody = "{ try { return ((cast) delegate).method($$); } catch (SQLException e) { _checkException(e); throw e;} }";
generateProxyClass(Statement.class, StatementProxy.class, methodBody);
generateProxyClass(CallableStatement.class, CallableStatementProxy.class, methodBody);
generateProxyClass(PreparedStatement.class, PreparedStatementProxy.class, methodBody);

@ -63,7 +63,8 @@ public abstract class PreparedStatementProxy extends StatementProxy implements I
}
catch (SQLException e)
{
throw _checkException(e);
_connection._checkException(e);
throw e;
}
}

@ -50,9 +50,9 @@ public abstract class ResultSetProxy implements IHikariResultSetProxy, ResultSet
}
@HikariInject
public SQLException _checkException(SQLException e)
public final void _checkException(SQLException e)
{
return _statement._checkException(e);
_statement._checkException(e);
}
@HikariInject

@ -81,9 +81,9 @@ public abstract class StatementProxy implements IHikariStatementProxy, Statement
}
@HikariInject
public SQLException _checkException(SQLException e)
public final void _checkException(SQLException e)
{
return _connection._checkException(e);
_connection._checkException(e);
}
@HikariInject
@ -122,7 +122,8 @@ public abstract class StatementProxy implements IHikariStatementProxy, Statement
}
catch (SQLException e)
{
throw _checkException(e);
_connection._checkException(e);
throw e;
}
}
@ -135,7 +136,8 @@ public abstract class StatementProxy implements IHikariStatementProxy, Statement
}
catch (SQLException e)
{
throw _checkException(e);
_connection._checkException(e);
throw e;
}
}
@ -148,7 +150,8 @@ public abstract class StatementProxy implements IHikariStatementProxy, Statement
}
catch (SQLException e)
{
throw _checkException(e);
_connection._checkException(e);
throw e;
}
}
@ -161,7 +164,8 @@ public abstract class StatementProxy implements IHikariStatementProxy, Statement
}
catch (SQLException e)
{
throw _checkException(e);
_connection._checkException(e);
throw e;
}
}

Loading…
Cancel
Save