From 24b359d51963b2eca4ff748e2d23fdc3b8f676dd Mon Sep 17 00:00:00 2001 From: Giuseppe Date: Wed, 22 Mar 2023 10:21:03 +0000 Subject: [PATCH] Handle all exceptions for stored proc out param retrieval in SharedEntityManagerCreator Prior to this commit, the EntityManager was not closed in SharedEntityManagerCreator.DeferredQueryInvocationHandler's invoke(Object, Method, Object[]) method if an invocation of getOutputParameterValue(*) threw an exception other than IllegalArgumentException, which could lead to a connection leak. This commit addresses this by catching RuntimeException instead of IllegalArgumentException. Closes gh-30161 --- .../org/springframework/orm/jpa/SharedEntityManagerCreator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java b/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java index 1b0446511744..911bbf3ba330 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java @@ -430,7 +430,7 @@ else if (targetClass.isInstance(proxy)) { entry.setValue(storedProc.getOutputParameterValue(key.toString())); } } - catch (IllegalArgumentException ex) { + catch (RuntimeException ex) { entry.setValue(ex); } }