diff --git a/pom.xml b/pom.xml index ce0e3145..176905f9 100644 --- a/pom.xml +++ b/pom.xml @@ -72,9 +72,9 @@ - net.jodah + dev.failsafe failsafe - 2.4.4 + 3.3.2 org.junit.jupiter diff --git a/src/main/java/com/saucelabs/saucerest/api/AbstractEndpoint.java b/src/main/java/com/saucelabs/saucerest/api/AbstractEndpoint.java index 96e0f791..39de9fe9 100644 --- a/src/main/java/com/saucelabs/saucerest/api/AbstractEndpoint.java +++ b/src/main/java/com/saucelabs/saucerest/api/AbstractEndpoint.java @@ -22,8 +22,8 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import net.jodah.failsafe.Failsafe; -import net.jodah.failsafe.RetryPolicy; +import dev.failsafe.Failsafe; +import dev.failsafe.RetryPolicy; import okhttp3.Credentials; import okhttp3.HttpUrl; @@ -283,21 +283,20 @@ private Response retryRequest(Request request) throws IOException { LOGGER.debug("Retrying request {} {}", request.method(), request.url()); response = Failsafe.with( - new RetryPolicy<>() - .handle( - RuntimeException.class, IOException.class, IllegalStateException.class) + RetryPolicy.builder() + .handle(RuntimeException.class, IOException.class, IllegalStateException.class) .withBackoff(BACKOFF_INITIAL_DELAY, BACKOFF_MULTIPLIER, ChronoUnit.MILLIS) .withMaxRetries(MAX_RETRIES) .onRetry( e -> { - if (e.getLastFailure() != null) { - LOGGER.warn( - "Retrying because of: {}", - e.getLastFailure().getClass().getSimpleName()); + Throwable lastException = e.getLastException(); + if (lastException != null) { + LOGGER.warn("Retrying because of: {}", lastException.getClass().getSimpleName()); } else { LOGGER.warn("Retrying"); } - })) + }) + .build()) .get(() -> getHttpClient().newCall(request).execute()); } catch (Exception e) { LOGGER.error("Error retrying request", e); diff --git a/src/main/java/com/saucelabs/saucerest/api/RealDevicesEndpoint.java b/src/main/java/com/saucelabs/saucerest/api/RealDevicesEndpoint.java index 6e1f1921..f6e9365e 100644 --- a/src/main/java/com/saucelabs/saucerest/api/RealDevicesEndpoint.java +++ b/src/main/java/com/saucelabs/saucerest/api/RealDevicesEndpoint.java @@ -11,8 +11,8 @@ import com.saucelabs.saucerest.model.realdevices.DeviceJob; import com.saucelabs.saucerest.model.realdevices.DeviceJobs; -import net.jodah.failsafe.Failsafe; -import net.jodah.failsafe.RetryPolicy; +import dev.failsafe.Failsafe; +import dev.failsafe.RetryPolicy; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -244,10 +244,11 @@ public String getAppiumServerVersion(String jobID) throws IOException { .frameworkLogUrl; // Retry policy to handle the case where the Appium version is not found in the log file RetryPolicy retryPolicy = - new RetryPolicy() + RetryPolicy. builder() .handleResultIf(Objects::isNull) .withMaxRetries(5) - .withDelay(Duration.ofSeconds(20)); + .withDelay(Duration.ofSeconds(20)) + .build(); String appiumVersion = Failsafe.with(retryPolicy)