Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
A stored procedure call (sql.call) fails, when any of the result-sets are NOT used in closure (param 3).
Cause
File: groovy.sql.Sql
Method: public void call(String sql, List<Object> params, Closure closure) throws Exception
The connection and statement is closed before result set
public void call(String sql, List<Object> params, Closure closure) throws Exception { ... } finally { closeResources(connection, statement); for (GroovyResultSet rs : resultSetResources) { closeResources(null, null, rs); } }
Here the 'closeResources(null, null, rs)' method in finally block fails, when the result-set is used for the first time here after the statement is closed.
if (firstCall) { resultSet = (ResultSet) call.getObject(indx + 1); firstCall = false; }
Suggested Fix
In class 'groovy.sql.Sql', method 'void call(String sql, List<Object> params, Closure closure)', switch the close connection/statement line after resultset.
for (GroovyResultSet rs : resultSetResources) { closeResources(null, null, rs); } closeResources(connection, statement);