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

CallableStatement leak in Sql.call() method

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.5
    • Fix Version/s: 2.4.7
    • Component/s: SQL processing
    • Labels:
      None

      Description

      All Sql.call(...) methods ultimately delegate to Sql.callWithRows(...) method where we have:

      try {
          statement = connection.prepareCall(sql);
          // ...
      } finally {
          // ...
          closeResources(connection, statement);
      }
      

      The problem is that statement is unconditionally parsed and compiled each time, but the closeResources() method only closes it when statement caching is disabled. So with statement caching enabled we end up allocating and leaking a new CallableStatement instance per Sql.call() invocation.

        Activity

        Hide
        githubbot ASF GitHub Bot added a comment -

        GitHub user jwagenleitner opened a pull request:

        https://github.com/apache/groovy/pull/263

        GROOVY-7751 - CallableStatement leak in Sql.call() method

        You can merge this pull request into a Git repository by running:

        $ git pull https://github.com/jwagenleitner/groovy GROOVY-7751

        Alternatively you can review and apply these changes as the patch at:

        https://github.com/apache/groovy/pull/263.patch

        To close this pull request, make a commit to your master/trunk branch
        with (at least) the following in the commit message:

        This closes #263


        commit 0b628560afaa56de550ee2bc5d076851612a8363
        Author: John Wagenleitner <jwagenleitner@apache.org>
        Date: 2016-02-13T20:57:04Z

        GROOVY-7751 - CallableStatement leak in Sql.call() method


        Show
        githubbot ASF GitHub Bot added a comment - GitHub user jwagenleitner opened a pull request: https://github.com/apache/groovy/pull/263 GROOVY-7751 - CallableStatement leak in Sql.call() method You can merge this pull request into a Git repository by running: $ git pull https://github.com/jwagenleitner/groovy GROOVY-7751 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/groovy/pull/263.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #263 commit 0b628560afaa56de550ee2bc5d076851612a8363 Author: John Wagenleitner <jwagenleitner@apache.org> Date: 2016-02-13T20:57:04Z GROOVY-7751 - CallableStatement leak in Sql.call() method
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user asfgit closed the pull request at:

        https://github.com/apache/groovy/pull/263

        Show
        githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/groovy/pull/263
        Hide
        jwagenleitner John Wagenleitner added a comment -

        Merged the PR that should ensure the CallableStatement's are added to the statement cache if caching is enabled.

        Thanks for reporting the issue.

        Show
        jwagenleitner John Wagenleitner added a comment - Merged the PR that should ensure the CallableStatement 's are added to the statement cache if caching is enabled. Thanks for reporting the issue.

          People

          • Assignee:
            jwagenleitner John Wagenleitner
            Reporter:
            avladykin Alexey Vladykin
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development