Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-17559

Potential resource leak in DataSourceUtils.doGetConnection

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 5.0.11, 5.1.3
    • Fix Version/s: 4.3.22, 5.0.12, 5.1.4
    • Component/s: Data:JDBC
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      Method doGetConnection in org.springframework.jdbc.datasource.DataSourceUtils has code that leaks (or has potential to leak) resources.

      Objects like logger, DataSource, Connection, etc are used or expected to be referenced between the connection is created and returned. Use of those objects can raise exceptions and cause a connection to be created but not returned from the function. This prevents the caller from being able to release that connection.

      The solution is simple and quite standard - try/catch clause is needed, see attachment.

      This affects all recent versions including 5.0.x and 5.1.x

        Attachments

          Activity

            People

            Assignee:
            juergen.hoeller Juergen Hoeller
            Reporter:
            cherio Yurx
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              3 years, 37 weeks, 5 days ago