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());

@ -40,9 +40,21 @@ public class PreparedStatementProxy extends StatementProxy
@HikariInject @HikariInject
public ResultSet executeQuery() throws SQLException public ResultSet executeQuery() throws SQLException
{ {
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __executeQuery(); try
resultSet.setProxyStatement(this); {
return (ResultSet) resultSet; 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 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,23 +64,54 @@ public class StatementProxy implements IHikariStatementProxy
public void close() throws SQLException public void close() throws SQLException
{ {
_connection.unregisterStatement(this); _connection.unregisterStatement(this);
__close(); try
{
__close();
}
catch (SQLException e)
{
throw checkException(e);
}
} }
@HikariInject
public ResultSet executeQuery(String sql) throws SQLException public ResultSet executeQuery(String sql) throws SQLException
{ {
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __executeQuery(sql); try
resultSet.setProxyStatement(this); {
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __executeQuery(sql);
return (ResultSet) resultSet; if (resultSet == null)
{
return null;
}
resultSet.setProxyStatement(this);
return (ResultSet) resultSet;
}
catch (SQLException e)
{
throw checkException(e);
}
} }
@HikariInject
public ResultSet getGeneratedKeys() throws SQLException public ResultSet getGeneratedKeys() throws SQLException
{ {
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __getGeneratedKeys(); try
resultSet.setProxyStatement(this); {
IHikariResultSetProxy resultSet = (IHikariResultSetProxy) __getGeneratedKeys();
return (ResultSet) resultSet; 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 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