protected boolean clearSpecial ( DatabaseConnection connection , Logger logger ) { NestedConnection currentSaved = specialConnection . get ( ) ; boolean cleared = false ; if ( connection == null ) { // ignored } else if ( currentSaved == null ) { logger . error ( "no connection has been saved when clear() called" ) ; } else if ( currentSaved . connection == connection ) { if ( currentSaved . decrementAndGet ( ) == 0 ) { // we only clear the connection if nested counter is 0 specialConnection . set ( null ) ; } cleared = true ; } else { logger . error ( "connection saved {} is not the one being cleared {}" , currentSaved . connection , connection ) ; } // release should then be called after clear return cleared ; }
Clear the connection that was previously saved .