mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-21 13:31:46 +00:00
Consistent maxAttempts (long) and delay/maxDelay (Duration) declarations
Includes timeUnit attribute in @Retryable (aligned with @Scheduled). See gh-34529 See gh-35110
This commit is contained in:
@@ -92,10 +92,10 @@ class RetryPolicyTests {
|
||||
void withMaxElapsedTimePreconditions() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> RetryPolicy.withMaxElapsedTime(Duration.ofMillis(0)))
|
||||
.withMessage("Invalid duration (0ms): max elapsed time must be positive.");
|
||||
.withMessage("Invalid duration (0ms): maxElapsedTime must be positive.");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> RetryPolicy.withMaxElapsedTime(Duration.ofMillis(-1)))
|
||||
.withMessage("Invalid duration (-1ms): max elapsed time must be positive.");
|
||||
.withMessage("Invalid duration (-1ms): maxElapsedTime must be positive.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -110,9 +110,9 @@ class RetryPolicyTests {
|
||||
.satisfies(hasDefaultMaxAttemptsAndDelay())
|
||||
.extracting(ExponentialBackOff::getMaxElapsedTime).isEqualTo(42L);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Nested
|
||||
class BuilderTests {
|
||||
|
||||
@@ -236,10 +236,10 @@ class RetryPolicyTests {
|
||||
void maxDelayPreconditions() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> RetryPolicy.builder().maxDelay(Duration.ofMillis(0)))
|
||||
.withMessage("Invalid duration (0ms): max delay must be positive.");
|
||||
.withMessage("Invalid duration (0ms): maxDelay must be positive.");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> RetryPolicy.builder().maxDelay(Duration.ofMillis(-1)))
|
||||
.withMessage("Invalid duration (-1ms): max delay must be positive.");
|
||||
.withMessage("Invalid duration (-1ms): maxDelay must be positive.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -258,10 +258,10 @@ class RetryPolicyTests {
|
||||
void maxElapsedTimePreconditions() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> RetryPolicy.builder().maxElapsedTime(Duration.ofMillis(0)))
|
||||
.withMessage("Invalid duration (0ms): max elapsed time must be positive.");
|
||||
.withMessage("Invalid duration (0ms): maxElapsedTime must be positive.");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> RetryPolicy.builder().maxElapsedTime(Duration.ofMillis(-1)))
|
||||
.withMessage("Invalid duration (-1ms): max elapsed time must be positive.");
|
||||
.withMessage("Invalid duration (-1ms): maxElapsedTime must be positive.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -399,6 +399,7 @@ class RetryPolicyTests {
|
||||
.matches("DefaultRetryPolicy\\[predicate=Predicate.+?Lambda.+?, backOff=ExponentialBackOff\\[.+?]]");
|
||||
}
|
||||
|
||||
|
||||
private static void assertToString(RetryPolicy policy, long initialInterval, long jitter,
|
||||
double multiplier, long maxInterval, long maxElapsedTime, int maxAttempts) {
|
||||
|
||||
@@ -431,9 +432,9 @@ class RetryPolicyTests {
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static ThrowingConsumer<? super ExponentialBackOff> hasDefaultMaxAttemptsAndDelay() {
|
||||
return backOff -> {
|
||||
assertThat(backOff.getMaxAttempts()).isEqualTo(3);
|
||||
@@ -441,6 +442,7 @@ class RetryPolicyTests {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private static class CustomNumberFormatException extends NumberFormatException {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user