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

Sql.withTransaction setAutoCommit in finally not wrapped in try/catch

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.6, 1.8.9, 2.1.6, 2.2.0-beta-1
    • 2.1.7, 2.2.0-beta-2
    • SQL processing
    • None

    Description

      When using an instance of Sql constructed with a DataSource, I experience a Connection Closed SQLException inside of withTransaction. In the finally clause, calling setAutoCommit(savedAutoCommit) causes another SQLException to be thrown. This means that cacheConnection remains true, and useConnection is still set. The connection is never closed and returned to the DataSource's pool which would allow it to be closed and a new one opened. The next time withTransaction is called, it uses the already set useConnection, which will throw the Connection Closed SQLException again.

      This should be fixable by simply wrapping the setAutoCommit in a try/catch just as the other parts of closeResources wrap their actions.

      Attachments

        Activity

          People

            pschumacher Pascal Schumacher
            jss Josh Spiewak
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: