From 4f1c8a4ba6902604c15aa70f07067f8f5fef7a56 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Thu, 1 Aug 2013 21:55:12 +0100 Subject: [PATCH] HHH-8407 Missing synchronization in DriverManagerConnectionProviderImpl#stop --- .../DriverManagerConnectionProviderImpl.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java index b21f694879..c1e6566f18 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java @@ -67,6 +67,7 @@ public class DriverManagerConnectionProviderImpl private int poolSize; private boolean autocommit; + //Access guarded by synchronization on the pool instance private final ArrayList pool = new ArrayList(); private final AtomicInteger checkedOut = new AtomicInteger(); @@ -166,15 +167,17 @@ public class DriverManagerConnectionProviderImpl public void stop() { LOG.cleaningUpConnectionPool( url ); - for ( Connection connection : pool ) { - try { - connection.close(); - } - catch (SQLException sqle) { - LOG.unableToClosePooledConnection( sqle ); + synchronized ( pool ) { + for ( Connection connection : pool ) { + try { + connection.close(); + } + catch (SQLException sqle) { + LOG.unableToClosePooledConnection( sqle ); + } } + pool.clear(); } - pool.clear(); stopped = true; }