Skip to content

Commit

Permalink
chore(deps): replace the old net.jodah:failsafe with dev.failsafe:fai…
Browse files Browse the repository at this point in the history
…lsafe
  • Loading branch information
lburgazzoli committed Oct 16, 2023
1 parent 9c44c72 commit 51d389c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ assertj = "3.24.2"
junit = "5.10.0"
testcontainers = "1.19.1"
protoc = "3.23.2"
failsafe = "2.4.4"
failsafe = "3.3.2"
awaitility = "4.2.0"
commonsIo = "2.14.0"
commonCompress = "1.24.0"
Expand All @@ -35,7 +35,7 @@ assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" }
junit = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
testcontainers = { module = "org.testcontainers:testcontainers", version.ref = "testcontainers" }
protoc = { module = "com.google.protobuf:protoc", version.ref = "protoc" }
failsafe = { module = "net.jodah:failsafe", version.ref = "failsafe" }
failsafe = { module = "dev.failsafe:failsafe", version.ref = "failsafe" }
awaitility = { module = "org.awaitility:awaitility", version.ref = "awaitility" }
picocli = { module = "info.picocli:picocli", version.ref = "picocli"}
restAssured = { module = "io.rest-assured:rest-assured", version.ref = "restAssured"}
Expand Down
20 changes: 10 additions & 10 deletions jetcd-core/src/main/java/io/etcd/jetcd/impl/Impl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
import java.util.function.Predicate;
import java.util.function.Supplier;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.etcd.jetcd.common.exception.EtcdExceptionFactory;
import io.etcd.jetcd.support.Errors;
import io.grpc.Status;
import io.vertx.core.Future;

import net.jodah.failsafe.Failsafe;
import net.jodah.failsafe.RetryPolicy;
import dev.failsafe.Failsafe;
import dev.failsafe.RetryPolicy;
import dev.failsafe.RetryPolicyBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static io.etcd.jetcd.support.Errors.isAuthStoreExpired;
import static io.etcd.jetcd.support.Errors.isInvalidTokenError;
Expand Down Expand Up @@ -116,21 +116,21 @@ protected <S, T> CompletableFuture<T> execute(
}

protected <S> RetryPolicy<S> retryPolicy(Predicate<Status> doRetry) {
RetryPolicy<S> policy = new RetryPolicy<S>()
RetryPolicyBuilder<S> policy = RetryPolicy.<S>builder()
.onFailure(e -> {
logger.warn("retry failure (attempt: {}, error: {})",
e.getAttemptCount(),
e.getFailure() != null ? e.getFailure().getMessage() : "<none>");
e.getException() != null ? e.getException().getMessage() : "<none>");
})
.onRetry(e -> {
logger.debug("retry (attempt: {}, error: {})",
e.getAttemptCount(),
e.getLastFailure() != null ? e.getLastFailure().getMessage() : "<none>");
e.getLastException() != null ? e.getLastException().getMessage() : "<none>");
})
.onRetriesExceeded(e -> {
logger.warn("maximum number of auto retries reached (attempt: {}, error: {})",
e.getAttemptCount(),
e.getFailure() != null ? e.getFailure().getMessage() : "<none>");
e.getException() != null ? e.getException().getMessage() : "<none>");
})
.handleIf(throwable -> {
Status status = Status.fromThrowable(throwable);
Expand All @@ -152,6 +152,6 @@ protected <S> RetryPolicy<S> retryPolicy(Predicate<Status> doRetry) {
policy = policy.withMaxDuration(connectionManager.builder().retryMaxDuration());
}

return policy;
return policy.build();
}
}

0 comments on commit 51d389c

Please sign in to comment.