Browse Source

Make @​Retryable timeout tests more robust

See gh-35963
pull/35990/head
Sam Brannen 1 week ago
parent
commit
a206ea8b12
  1. 8
      spring-context/src/test/java/org/springframework/resilience/ReactiveRetryInterceptorTests.java
  2. 8
      spring-context/src/test/java/org/springframework/resilience/RetryInterceptorTests.java

8
spring-context/src/test/java/org/springframework/resilience/ReactiveRetryInterceptorTests.java

@ -481,23 +481,23 @@ class ReactiveRetryInterceptorTests {
}); });
} }
@Retryable(timeout = 5, delay = 0) @Retryable(timeout = 20, delay = 0)
public Mono<Object> retryOperationWithTimeoutExceededAfterFirstRetry() { public Mono<Object> retryOperationWithTimeoutExceededAfterFirstRetry() {
return Mono.fromCallable(() -> { return Mono.fromCallable(() -> {
counter.incrementAndGet(); counter.incrementAndGet();
if (counter.get() == 2) { if (counter.get() == 2) {
Thread.sleep(10); Thread.sleep(50);
} }
throw new IOException(counter.toString()); throw new IOException(counter.toString());
}); });
} }
@Retryable(timeout = 5, delay = 0) @Retryable(timeout = 20, delay = 0)
public Mono<Object> retryOperationWithTimeoutExceededAfterSecondRetry() { public Mono<Object> retryOperationWithTimeoutExceededAfterSecondRetry() {
return Mono.fromCallable(() -> { return Mono.fromCallable(() -> {
counter.incrementAndGet(); counter.incrementAndGet();
if (counter.get() == 3) { if (counter.get() == 3) {
Thread.sleep(10); Thread.sleep(50);
} }
throw new IOException(counter.toString()); throw new IOException(counter.toString());
}); });

8
spring-context/src/test/java/org/springframework/resilience/RetryInterceptorTests.java

@ -439,20 +439,20 @@ class RetryInterceptorTests {
throw new IOException(Integer.toString(counter)); throw new IOException(Integer.toString(counter));
} }
@Retryable(timeout = 5, delay = 0) @Retryable(timeout = 20, delay = 0)
public void retryOperationWithTimeoutExceededAfterFirstRetry() throws Exception { public void retryOperationWithTimeoutExceededAfterFirstRetry() throws Exception {
counter++; counter++;
if (counter == 2) { if (counter == 2) {
Thread.sleep(10); Thread.sleep(50);
} }
throw new IOException(Integer.toString(counter)); throw new IOException(Integer.toString(counter));
} }
@Retryable(timeout = 5, delay = 0) @Retryable(timeout = 20, delay = 0)
public void retryOperationWithTimeoutExceededAfterSecondRetry() throws Exception { public void retryOperationWithTimeoutExceededAfterSecondRetry() throws Exception {
counter++; counter++;
if (counter == 3) { if (counter == 3) {
Thread.sleep(10); Thread.sleep(50);
} }
throw new IOException(Integer.toString(counter)); throw new IOException(Integer.toString(counter));
} }

Loading…
Cancel
Save