protected synchronized void stealExistingAllocations ( ) { for ( ConnectionHandle handle : this . threadFinalizableRefs . keySet ( ) ) { // if they're not in use, pretend they are in use now and close them off. // this method assumes that the strategy has been flipped back to non-caching mode // prior to this method invocation. if ( handle . logicallyClosed . compareAndSet ( true , false ) ) { try { this . pool . releaseConnection ( handle ) ; } catch ( SQLException e ) { logger . error ( "Error releasing connection" , e ) ; } } } if ( this . warnApp . compareAndSet ( false , true ) ) { // only issue warning once. logger . warn ( "Cached strategy chosen, but more threads are requesting a connection than are configured. Switching permanently to default strategy." ) ; } this . threadFinalizableRefs . clear ( ) ; }
Tries to close off all the unused assigned connections back to the pool . Assumes that the strategy mode has already been flipped prior to calling this routine . Called whenever our no of connection requests > no of threads .