@@ -625,8 +625,11 @@ void shouldRetryAsyncOnTimeoutAndSucceed() throws Exception {
625625 TimeoutException timeoutException = new TimeoutException ("read" , "Timeout" , new Exception ());
626626 Response successResponse = createSuccessResponse ();
627627
628+ CompletableFuture <Response > failedFuture = new CompletableFuture <>();
629+ failedFuture .completeExceptionally (timeoutException );
630+
628631 when (mockTransport .sendAsync (any (Request .class )))
629- .thenReturn (CompletableFuture . failedFuture ( timeoutException ) )
632+ .thenReturn (failedFuture )
630633 .thenReturn (CompletableFuture .completedFuture (successResponse ));
631634
632635 RetryConfig retryConfig = RetryConfig .builder ()
@@ -661,8 +664,11 @@ void shouldRetryAsyncOnNetworkExceptionAndSucceed() throws Exception {
661664 NetworkException networkException = new NetworkException ("Network error" , new Exception ());
662665 Response successResponse = createSuccessResponse ();
663666
667+ CompletableFuture <Response > failedFuture = new CompletableFuture <>();
668+ failedFuture .completeExceptionally (networkException );
669+
664670 when (mockTransport .sendAsync (any (Request .class )))
665- .thenReturn (CompletableFuture . failedFuture ( networkException ) )
671+ .thenReturn (failedFuture )
666672 .thenReturn (CompletableFuture .completedFuture (successResponse ));
667673
668674 RetryConfig retryConfig = RetryConfig .builder ()
@@ -696,8 +702,11 @@ void shouldFailAsyncAfterMaxRetries() throws Exception {
696702 Transport mockTransport = mock (Transport .class );
697703 NetworkException networkException = new NetworkException ("Network error" , new Exception ());
698704
705+ CompletableFuture <Response > failedFuture = new CompletableFuture <>();
706+ failedFuture .completeExceptionally (networkException );
707+
699708 when (mockTransport .sendAsync (any (Request .class )))
700- .thenReturn (CompletableFuture . failedFuture ( networkException ) );
709+ .thenReturn (failedFuture );
701710
702711 RetryConfig retryConfig = RetryConfig .builder ()
703712 .enabled (true )
@@ -796,8 +805,11 @@ void shouldNotRetryAsyncOnNonRetryableException() throws Exception {
796805 Transport mockTransport = mock (Transport .class );
797806 ConfigurationException configException = new ConfigurationException ("Invalid config" );
798807
808+ CompletableFuture <Response > failedFuture = new CompletableFuture <>();
809+ failedFuture .completeExceptionally (configException );
810+
799811 when (mockTransport .sendAsync (any (Request .class )))
800- .thenReturn (CompletableFuture . failedFuture ( configException ) );
812+ .thenReturn (failedFuture );
801813
802814 RetryConfig retryConfig = RetryConfig .builder ()
803815 .enabled (true )
0 commit comments