Skip to content

Potential resource leak in DataSourceUtils.doGetConnection [SPR-17559] #22091

@spring-projects-issues

Description

@spring-projects-issues

Yurx opened SPR-17559 and commented

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


Affects: 5.0.11, 5.1.3

Attachments:

Backported to: 5.0.12, 4.3.22

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions