Skip to content

Commit d12619c

Browse files
committed
Raise log level for exceptions from EntityManager close call
Closes gh-24501
1 parent 4c1d227 commit d12619c

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -505,7 +505,7 @@ protected void closeConnection(Connection con) {
505505
logger.debug("Ignoring Connection state exception - assuming already closed: " + ex);
506506
}
507507
catch (Throwable ex) {
508-
logger.debug("Could not close shared JMS Connection", ex);
508+
logger.warn("Could not close shared JMS Connection", ex);
509509
}
510510
}
511511

spring-orm/src/main/java/org/springframework/orm/hibernate5/SessionFactoryUtils.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -170,11 +170,8 @@ public static void closeSession(@Nullable Session session) {
170170
try {
171171
session.close();
172172
}
173-
catch (HibernateException ex) {
174-
logger.debug("Could not close Hibernate Session", ex);
175-
}
176173
catch (Throwable ex) {
177-
logger.debug("Unexpected exception on closing Hibernate Session", ex);
174+
logger.error("Failed to release Hibernate Session", ex);
178175
}
179176
}
180177
}

spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -427,11 +427,8 @@ public static void closeEntityManager(@Nullable EntityManager em) {
427427
em.close();
428428
}
429429
}
430-
catch (PersistenceException ex) {
431-
logger.debug("Could not close JPA EntityManager", ex);
432-
}
433430
catch (Throwable ex) {
434-
logger.debug("Unexpected exception on closing JPA EntityManager", ex);
431+
logger.error("Failed to release JPA EntityManager", ex);
435432
}
436433
}
437434
}

spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -603,9 +603,9 @@ protected void doCleanupAfterCompletion(Object transaction) {
603603
getJpaDialect().releaseJdbcConnection(conHandle,
604604
txObject.getEntityManagerHolder().getEntityManager());
605605
}
606-
catch (Exception ex) {
606+
catch (Throwable ex) {
607607
// Just log it, to keep a transaction-related exception.
608-
logger.error("Could not close JDBC connection after transaction", ex);
608+
logger.error("Failed to release JDBC connection after transaction", ex);
609609
}
610610
}
611611
}

0 commit comments

Comments
 (0)