final public void close ( ) { List < C > connsToClose ; synchronized ( poolLock ) { // Prevent any new connections isClosed = true ; // Find any connections that are available and open connsToClose = new ArrayList <> ( availableConnections . size ( ) ) ; for ( PooledConnection < C > availableConnection : availableConnections ) { synchronized ( availableConnection ) { C conn = availableConnection . connection ; if ( conn != null ) { availableConnection . connection = null ; connsToClose . add ( conn ) ; } } } poolLock . notifyAll ( ) ; } // Close all of the connections for ( C conn : connsToClose ) { try { close ( conn ) ; } catch ( Exception err ) { logger . log ( Level . WARNING , null , err ) ; } } }
Shuts down the pool exceptions during close will be logged as a warning and not thrown .