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())) 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())) 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())) 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())) 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('}'); call.append('}');
method.setBody(call.toString()); method.setBody(call.toString());

@ -39,11 +39,23 @@ public class PreparedStatementProxy extends StatementProxy
@HikariInject @HikariInject
public ResultSet executeQuery() throws SQLException public ResultSet executeQuery() throws SQLException
{
try
{ {
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __executeQuery(); IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __executeQuery();
if (resultSet == null)
{
return null;
}
resultSet.setProxyStatement(this); resultSet.setProxyStatement(this);
return (ResultSet) resultSet; return (ResultSet) resultSet;
} }
catch (SQLException e)
{
throw checkException(e);
}
}
// *********************************************************************** // ***********************************************************************
// These methods contain code we do not want injected into the actual // These methods contain code we do not want injected into the actual
@ -55,10 +67,6 @@ public class PreparedStatementProxy extends StatementProxy
public ResultSet __executeQuery() throws SQLException public ResultSet __executeQuery() throws SQLException
{ {
ResultSet resultSet = ((PreparedStatement) delegate).executeQuery(); ResultSet resultSet = ((PreparedStatement) delegate).executeQuery();
if (resultSet == null)
{
return null;
}
return PROXY_FACTORY.getProxyResultSet(this, resultSet); return PROXY_FACTORY.getProxyResultSet(this, resultSet);
} }

@ -64,24 +64,55 @@ public class StatementProxy implements IHikariStatementProxy
public void close() throws SQLException public void close() throws SQLException
{ {
_connection.unregisterStatement(this); _connection.unregisterStatement(this);
try
{
__close(); __close();
} }
catch (SQLException e)
{
throw checkException(e);
}
}
@HikariInject
public ResultSet executeQuery(String sql) throws SQLException public ResultSet executeQuery(String sql) throws SQLException
{
try
{ {
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __executeQuery(sql); IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __executeQuery(sql);
resultSet.setProxyStatement(this); if (resultSet == null)
{
return null;
}
resultSet.setProxyStatement(this);
return (ResultSet) resultSet; return (ResultSet) resultSet;
} }
catch (SQLException e)
{
throw checkException(e);
}
}
@HikariInject
public ResultSet getGeneratedKeys() throws SQLException public ResultSet getGeneratedKeys() throws SQLException
{
try
{ {
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __getGeneratedKeys(); IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __getGeneratedKeys();
resultSet.setProxyStatement(this); if (resultSet == null)
{
return null;
}
resultSet.setProxyStatement(this);
return (ResultSet) resultSet; return (ResultSet) resultSet;
} }
catch (SQLException e)
{
throw checkException(e);
}
}
// *********************************************************************** // ***********************************************************************
// These methods contain code we do not want injected into the actual // These methods contain code we do not want injected into the actual
@ -111,22 +142,12 @@ public class StatementProxy implements IHikariStatementProxy
public ResultSet __executeQuery(String sql) throws SQLException public ResultSet __executeQuery(String sql) throws SQLException
{ {
ResultSet resultSet = delegate.executeQuery(sql); ResultSet resultSet = delegate.executeQuery(sql);
if (resultSet == null)
{
return null;
}
return PROXY_FACTORY.getProxyResultSet(this, resultSet); return PROXY_FACTORY.getProxyResultSet(this, resultSet);
} }
public ResultSet __getGeneratedKeys() throws SQLException public ResultSet __getGeneratedKeys() throws SQLException
{ {
ResultSet generatedKeys = delegate.getGeneratedKeys(); ResultSet generatedKeys = delegate.getGeneratedKeys();
if (generatedKeys == null)
{
return null;
}
return PROXY_FACTORY.getProxyResultSet(this, generatedKeys); return PROXY_FACTORY.getProxyResultSet(this, generatedKeys);
} }

Loading…
Cancel
Save