diff --git a/jdbc/src/main/java/org/springframework/transaction/support/TransactionSynchronizationManager.java b/jdbc/src/main/java/org/springframework/transaction/support/TransactionSynchronizationManager.java index 6af90dda51..c422eae03a 100644 --- a/jdbc/src/main/java/org/springframework/transaction/support/TransactionSynchronizationManager.java +++ b/jdbc/src/main/java/org/springframework/transaction/support/TransactionSynchronizationManager.java @@ -31,7 +31,9 @@ public static void bindResource(DataSource key, Connection value) { public static Connection unbindResource(DataSource key) { Map dataSourceConnectionMap = resources.get(); Connection remove = dataSourceConnectionMap.remove(key); - resources.remove(); + if (dataSourceConnectionMap.isEmpty()) { + resources.remove(); + } return remove; } }