Skip to content

SharedEntityManagerCreator does not handle all exceptions for stored proc output param retrieval #30160

@giuseppemilicia

Description

@giuseppemilicia

Affects: Spring Boot 6.0.4

In the SharedEntityManagerCreator class, the following code block invokes getOutputParameterValue which can throw a HibernateException.

try {
Object key = entry.getKey();
if (key instanceof Integer number) {
entry.setValue(storedProc.getOutputParameterValue(number));
}
else {
entry.setValue(storedProc.getOutputParameterValue(key.toString()));
}
}
catch (IllegalArgumentException ex) {
entry.setValue(ex);
}

The problem is that the catch block only handles IllegalArgumentException.

This causes a connection leak in the HikariCP pool because the subsequent EntityManagerFactoryUtils.closeEntityManager(this.entityManager); line will never be executed, and the entity manager will never be closed.

A possible solution is to change the catch block to handle the more general Exception or RuntimeException instead of IllegalArgumentException.

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)status: supersededAn issue that has been superseded by anothertype: bugA general bug

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions