Skip to content

Commit 38cf4ab

Browse files
committed
Make RetryTemplate timeout tests more robust
See gh-35963
1 parent 2137ec7 commit 38cf4ab

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

spring-core/src/test/java/org/springframework/core/retry/RetryTemplateTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ void retryWithTimeoutExceededAfterFirstDelayButBeforeFirstRetry() throws Excepti
517517
@Test
518518
void retryWithTimeoutExceededAfterFirstRetry() throws Exception {
519519
RetryPolicy retryPolicy = RetryPolicy.builder()
520-
.timeout(Duration.ofMillis(5))
520+
.timeout(Duration.ofMillis(20))
521521
.delay(Duration.ZERO)
522522
.build();
523523
RetryTemplate retryTemplate = new RetryTemplate(retryPolicy);
@@ -527,15 +527,15 @@ void retryWithTimeoutExceededAfterFirstRetry() throws Exception {
527527
Retryable<String> retryable = () -> {
528528
int currentInvocation = invocationCount.incrementAndGet();
529529
if (currentInvocation == 2) {
530-
Thread.sleep(10);
530+
Thread.sleep(50);
531531
}
532532
throw new CustomException("Boom " + currentInvocation);
533533
};
534534

535535
assertThat(invocationCount).hasValue(0);
536536
assertThatExceptionOfType(RetryException.class)
537537
.isThrownBy(() -> retryTemplate.execute(retryable))
538-
.withMessageMatching("Retry policy for operation '.+?' exceeded timeout \\(5 ms\\); aborting execution")
538+
.withMessageMatching("Retry policy for operation '.+?' exceeded timeout \\(20 ms\\); aborting execution")
539539
.withCause(new CustomException("Boom 2"))
540540
.satisfies(throwable -> {
541541
inOrder.verify(retryListener).beforeRetry(retryPolicy, retryable);
@@ -552,7 +552,7 @@ void retryWithTimeoutExceededAfterFirstRetry() throws Exception {
552552
@Test
553553
void retryWithTimeoutExceededAfterSecondRetry() throws Exception {
554554
RetryPolicy retryPolicy = RetryPolicy.builder()
555-
.timeout(Duration.ofMillis(5))
555+
.timeout(Duration.ofMillis(20))
556556
.delay(Duration.ZERO)
557557
.build();
558558
RetryTemplate retryTemplate = new RetryTemplate(retryPolicy);
@@ -562,15 +562,15 @@ void retryWithTimeoutExceededAfterSecondRetry() throws Exception {
562562
Retryable<String> retryable = () -> {
563563
int currentInvocation = invocationCount.incrementAndGet();
564564
if (currentInvocation == 3) {
565-
Thread.sleep(10);
565+
Thread.sleep(50);
566566
}
567567
throw new CustomException("Boom " + currentInvocation);
568568
};
569569

570570
assertThat(invocationCount).hasValue(0);
571571
assertThatExceptionOfType(RetryException.class)
572572
.isThrownBy(() -> retryTemplate.execute(retryable))
573-
.withMessageMatching("Retry policy for operation '.+?' exceeded timeout \\(5 ms\\); aborting execution")
573+
.withMessageMatching("Retry policy for operation '.+?' exceeded timeout \\(20 ms\\); aborting execution")
574574
.withCause(new CustomException("Boom 3"))
575575
.satisfies(throwable -> {
576576
var counter = new AtomicInteger(1);

0 commit comments

Comments
 (0)