2222import static java .net .HttpURLConnection .HTTP_UNAVAILABLE ;
2323import static org .openqa .selenium .internal .Debug .getDebugLogLevel ;
2424
25- import net . jodah .failsafe .Failsafe ;
26- import net . jodah .failsafe .RetryPolicy ;
25+ import dev .failsafe .Failsafe ;
26+ import dev .failsafe .RetryPolicy ;
2727
2828import org .openqa .selenium .TimeoutException ;
2929
@@ -36,39 +36,42 @@ public class RetryRequest implements Filter {
3636 private static final Logger LOG = Logger .getLogger (RetryRequest .class .getName ());
3737
3838 // Retry on connection error.
39- private static final RetryPolicy <HttpResponse > connectionFailurePolicy =
40- new RetryPolicy < HttpResponse > ()
39+ private static final RetryPolicy <Object > connectionFailurePolicy =
40+ RetryPolicy . builder ()
4141 .handleIf (failure -> failure .getCause () instanceof ConnectException )
4242 .withBackoff (1 , 4 , ChronoUnit .SECONDS )
4343 .withMaxRetries (3 )
4444 .onRetry (e -> LOG .log (
4545 getDebugLogLevel (),
4646 "Connection failure #{0}. Retrying." ,
47- e .getAttemptCount ()));
47+ e .getAttemptCount ()))
48+ .build ();
4849
4950 // Retry on read timeout.
50- private static final RetryPolicy <HttpResponse > readTimeoutPolicy =
51- new RetryPolicy < HttpResponse > ()
51+ private static final RetryPolicy <Object > readTimeoutPolicy =
52+ RetryPolicy . builder ()
5253 .handle (TimeoutException .class )
5354 .withBackoff (1 , 4 , ChronoUnit .SECONDS )
5455 .withMaxRetries (3 )
5556 .onRetry (e -> LOG .log (
5657 getDebugLogLevel (),
5758 "Read timeout #{0}. Retrying." ,
58- e .getAttemptCount ()));
59+ e .getAttemptCount ()))
60+ .build ();
5961
6062 // Retry if server is unavailable or an internal server error occurs without response body.
61- private static final RetryPolicy <HttpResponse > serverErrorPolicy =
62- new RetryPolicy < HttpResponse > ()
63- .handleResultIf (response -> response .getStatus () == HTTP_INTERNAL_ERROR &&
64- Integer .parseInt (response .getHeader (CONTENT_LENGTH )) == 0 )
65- .handleResultIf (response -> response .getStatus () == HTTP_UNAVAILABLE )
63+ private static final RetryPolicy <Object > serverErrorPolicy =
64+ RetryPolicy . builder ()
65+ .handleResultIf (response -> (( HttpResponse ) response ) .getStatus () == HTTP_INTERNAL_ERROR &&
66+ Integer .parseInt ((( HttpResponse ) response ) .getHeader (CONTENT_LENGTH )) == 0 )
67+ .handleResultIf (response -> (( HttpResponse ) response ) .getStatus () == HTTP_UNAVAILABLE )
6668 .withBackoff (1 , 2 , ChronoUnit .SECONDS )
6769 .withMaxRetries (2 )
6870 .onRetry (e -> LOG .log (
6971 getDebugLogLevel (),
7072 "Failure due to server error #{0}. Retrying." ,
71- e .getAttemptCount ()));
73+ e .getAttemptCount ()))
74+ .build ();
7275
7376 @ Override
7477 public HttpHandler apply (HttpHandler next ) {
0 commit comments