Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6420

A stored procedure call (sql.call) fails, when any of the result-sets are NOT used in closure (param 3).

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.3.1
    • SQL processing
    • 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

      groovy.sql.Sql
      	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.

      groovy.sql.CallResultSet
      	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.

      groovy.sql.Sql
           
          for (GroovyResultSet rs : resultSetResources) {
              closeResources(null, null, rs);
          }
          closeResources(connection, statement);
      

      Attachments

        Activity

          People

            paulk Paul King
            tomjoseph Tom Joseph
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: