HHH-8407 Missing synchronization in DriverManagerConnectionProviderImpl#stop

This commit is contained in:
Sanne Grinovero 2013-08-01 21:55:12 +01:00
parent 59d2bff81b
commit 4f1c8a4ba6
1 changed files with 10 additions and 7 deletions

View File

@ -67,6 +67,7 @@ public class DriverManagerConnectionProviderImpl
private int poolSize;
private boolean autocommit;
//Access guarded by synchronization on the pool instance
private final ArrayList<Connection> pool = new ArrayList<Connection>();
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;
}