Skip to content

Commit

Permalink
Fix incorrect exceptions thrown by RetryPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Jul 10, 2024
1 parent 88b6bb5 commit 2d2a41e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/io/vertx/circuitbreaker/RetryPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface RetryPolicy {
*/
static RetryPolicy constantDelay(long delay) {
if (delay <= 0) {
throw new IllegalStateException("delay must be strictly positive");
throw new IllegalArgumentException("delay must be strictly positive");
}
return (failure, retryCount) -> delay;
}
Expand All @@ -44,10 +44,10 @@ static RetryPolicy constantDelay(long delay) {
*/
static RetryPolicy linearDelay(long initialDelay, long maxDelay) {
if (initialDelay <= 0) {
throw new IllegalStateException("initialDelay must be strictly positive");
throw new IllegalArgumentException("initialDelay must be strictly positive");
}
if (maxDelay < initialDelay) {
throw new IllegalStateException("maxDelay must be greater than initialDelay");
throw new IllegalArgumentException("maxDelay must be greater than initialDelay");
}
return (failure, retryCount) -> min(maxDelay, initialDelay * retryCount);
}
Expand All @@ -63,10 +63,10 @@ static RetryPolicy linearDelay(long initialDelay, long maxDelay) {
*/
static RetryPolicy exponentialDelayWithJitter(long initialDelay, long maxDelay) {
if (initialDelay <= 0) {
throw new IllegalStateException("initialDelay must be strictly positive");
throw new IllegalArgumentException("initialDelay must be strictly positive");
}
if (maxDelay < initialDelay) {
throw new IllegalStateException("maxDelay must be greater than initialDelay");
throw new IllegalArgumentException("maxDelay must be greater than initialDelay");
}
return (failure, retryCount) -> {
ThreadLocalRandom random = ThreadLocalRandom.current();
Expand Down

0 comments on commit 2d2a41e

Please sign in to comment.