Check open status before close call (aligned with EntityManagerFactoryUtils)
Closes gh-27972
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -133,7 +133,9 @@ public abstract class SessionFactoryUtils {
|
|||||||
public static void closeSession(@Nullable Session session) {
|
public static void closeSession(@Nullable Session session) {
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
try {
|
try {
|
||||||
session.close();
|
if (session.isOpen()) {
|
||||||
|
session.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Throwable ex) {
|
catch (Throwable ex) {
|
||||||
logger.error("Failed to release Hibernate Session", ex);
|
logger.error("Failed to release Hibernate Session", ex);
|
||||||
|
|||||||
Reference in New Issue
Block a user