ConnectionPoolImpl implements ConnectionPool { @Override public void retainAll( Set<BoltServerAddress> addressesToRetain ) { for ( BoltServerAddress address : pools.keySet() ) { if ( !addressesToRetain.contains( address ) ) { int activeChannels = nettyChannelTracker.inUseChannelCount( address ); if ( activeChannels == 0 ) { ExtendedChannelPool pool = pools.remove( address ); if ( pool != null ) { log.info( "Closing connection pool towards %s, it has no active connections " + "and is not in the routing table registry.", address ); closePoolInBackground( address, pool ); } } } } } ConnectionPoolImpl( ChannelConnector connector, Bootstrap bootstrap, PoolSettings settings, MetricsListener metricsListener, Logging logging,
            Clock clock, boolean ownsEventLoopGroup );  ConnectionPoolImpl( ChannelConnector connector, Bootstrap bootstrap, NettyChannelTracker nettyChannelTracker, PoolSettings settings,
            MetricsListener metricsListener, Logging logging, Clock clock, boolean ownsEventLoopGroup, ConnectionFactory connectionFactory ); @Override CompletionStage<Connection> acquire( BoltServerAddress address ); @Override void retainAll( Set<BoltServerAddress> addressesToRetain ); @Override int inUseConnections( BoltServerAddress address ); @Override int idleConnections( BoltServerAddress address ); @Override CompletionStage<Void> close(); @Override boolean isOpen( BoltServerAddress address ); @Override String toString();  }
@Test void shouldDoNothingWhenRetainOnEmptyPool() { NettyChannelTracker nettyChannelTracker = mock( NettyChannelTracker.class ); TestConnectionPool pool = newConnectionPool( nettyChannelTracker ); pool.retainAll( singleton( LOCAL_DEFAULT ) ); verifyZeroInteractions( nettyChannelTracker ); }