Affects: Spring Boot 6.0.4

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

https://github.com/spring-projects/spring-framework/blob/800b13492b627d02da5d3591ee9ae9c04833da81/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java#L424-L435

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.

Comment From: sbrannen

I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference.

Comment From: sbrannen

  • Superseded by #30161