LoadBalancer implements ConnectionProvider { @Override public CompletionStage<Boolean> supportsMultiDb() { List<BoltServerAddress> addresses; try { addresses = rediscovery.resolve(); } catch ( Throwable error ) { return failedFuture( error ); } CompletableFuture<Boolean> result = completedWithNull(); Throwable baseError = new ServiceUnavailableException( "Failed to perform multi-databases feature detection with the following servers: " + addresses ); for ( BoltServerAddress address : addresses ) { result = onErrorContinue( result, baseError, completionError -> { Throwable error = completionExceptionCause( completionError ); if ( error instanceof SecurityException ) { return failedFuture( error ); } return supportsMultiDb( address ); } ); } return onErrorContinue( result, baseError, completionError -> { Throwable error = completionExceptionCause( completionError ); if ( error instanceof SecurityException ) { return failedFuture( error ); } return failedFuture( baseError ); } ); } LoadBalancer( BoltServerAddress initialRouter, RoutingSettings settings, ConnectionPool connectionPool,
            EventExecutorGroup eventExecutorGroup, Clock clock, Logging logging,
            LoadBalancingStrategy loadBalancingStrategy, ServerAddressResolver resolver ); private  LoadBalancer( ConnectionPool connectionPool, Rediscovery rediscovery, RoutingSettings settings, LoadBalancingStrategy loadBalancingStrategy,
            EventExecutorGroup eventExecutorGroup, Clock clock, Logger log );   LoadBalancer( ConnectionPool connectionPool, RoutingTableRegistry routingTables, Rediscovery rediscovery, LoadBalancingStrategy loadBalancingStrategy,
            EventExecutorGroup eventExecutorGroup, Logger log ); @Override CompletionStage<Connection> acquireConnection( ConnectionContext context ); @Override CompletionStage<Void> verifyConnectivity(); @Override CompletionStage<Void> close(); @Override CompletionStage<Boolean> supportsMultiDb();  }
@Test void shouldFailWithResolverError() throws Throwable { ConnectionPool pool = mock( ConnectionPool.class ); Rediscovery rediscovery = mock( Rediscovery.class ); when( rediscovery.resolve() ).thenThrow( new RuntimeException( "hi there" ) ); LoadBalancer loadBalancer = newLoadBalancer( pool, rediscovery ); RuntimeException exception = assertThrows( RuntimeException.class, () -> await( loadBalancer.supportsMultiDb() ) ); assertThat( exception.getMessage(), equalTo( "hi there" ) ); }