Fixup null check

pull/1/head
Brett Wooldridge 11 years ago
parent 8fcbc29ce9
commit abadd6723a

@ -100,19 +100,19 @@ public final class JavassistProxyFactoryFactory
}
if ("getProxyStatement".equals(method.getName()))
{
call.append("return new com.zaxxer.hikari.proxy.StatementJavassistProxy($$);");
call.append("return $2 != null ? new com.zaxxer.hikari.proxy.StatementJavassistProxy($$) : null;");
}
if ("getProxyPreparedStatement".equals(method.getName()))
{
call.append("return new com.zaxxer.hikari.proxy.PreparedStatementJavassistProxy($$);");
call.append("return $2 != null ? new com.zaxxer.hikari.proxy.PreparedStatementJavassistProxy($$) : null;");
}
if ("getProxyResultSet".equals(method.getName()))
{
call.append("return new com.zaxxer.hikari.proxy.ResultSetJavassistProxy($$);");
call.append("return $2 != null ? new com.zaxxer.hikari.proxy.ResultSetJavassistProxy($$) : null;");
}
if ("getProxyCallableStatement".equals(method.getName()))
{
call.append("return new com.zaxxer.hikari.proxy.CallableStatementJavassistProxy($$);");
call.append("return $2 != null ? new com.zaxxer.hikari.proxy.CallableStatementJavassistProxy($$) : null;");
}
call.append('}');
method.setBody(call.toString());

@ -40,9 +40,21 @@ public class PreparedStatementProxy extends StatementProxy
@HikariInject
public ResultSet executeQuery() throws SQLException
{
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __executeQuery();
resultSet.setProxyStatement(this);
return (ResultSet) resultSet;
try
{
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __executeQuery();
if (resultSet == null)
{
return null;
}
resultSet.setProxyStatement(this);
return (ResultSet) resultSet;
}
catch (SQLException e)
{
throw checkException(e);
}
}
// ***********************************************************************
@ -55,10 +67,6 @@ public class PreparedStatementProxy extends StatementProxy
public ResultSet __executeQuery() throws SQLException
{
ResultSet resultSet = ((PreparedStatement) delegate).executeQuery();
if (resultSet == null)
{
return null;
}
return PROXY_FACTORY.getProxyResultSet(this, resultSet);
}

@ -64,23 +64,54 @@ public class StatementProxy implements IHikariStatementProxy
public void close() throws SQLException
{
_connection.unregisterStatement(this);
__close();
try
{
__close();
}
catch (SQLException e)
{
throw checkException(e);
}
}
@HikariInject
public ResultSet executeQuery(String sql) throws SQLException
{
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __executeQuery(sql);
resultSet.setProxyStatement(this);
return (ResultSet) resultSet;
try
{
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __executeQuery(sql);
if (resultSet == null)
{
return null;
}
resultSet.setProxyStatement(this);
return (ResultSet) resultSet;
}
catch (SQLException e)
{
throw checkException(e);
}
}
@HikariInject
public ResultSet getGeneratedKeys() throws SQLException
{
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __getGeneratedKeys();
resultSet.setProxyStatement(this);
return (ResultSet) resultSet;
try
{
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __getGeneratedKeys();
if (resultSet == null)
{
return null;
}
resultSet.setProxyStatement(this);
return (ResultSet) resultSet;
}
catch (SQLException e)
{
throw checkException(e);
}
}
// ***********************************************************************
@ -111,22 +142,12 @@ public class StatementProxy implements IHikariStatementProxy
public ResultSet __executeQuery(String sql) throws SQLException
{
ResultSet resultSet = delegate.executeQuery(sql);
if (resultSet == null)
{
return null;
}
return PROXY_FACTORY.getProxyResultSet(this, resultSet);
}
public ResultSet __getGeneratedKeys() throws SQLException
{
ResultSet generatedKeys = delegate.getGeneratedKeys();
if (generatedKeys == null)
{
return null;
}
return PROXY_FACTORY.getProxyResultSet(this, generatedKeys);
}

Loading…
Cancel
Save