mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-25 08:19:01 +00:00
Introduce RetryInterruptedException to address off-by-one error
Prior to this commit, a RetryException thrown for an InterruptedException returned the wrong value from getRetryCount(). Specifically, the count was one more than it should have been, since the suppressed exception list contains the initial exception as well as all retry attempt exceptions. To address that, this commit introduces an internal RetryInterruptedException which accounts for this off-by-one error. Closes gh-35434
This commit is contained in:
@@ -238,9 +238,7 @@ class RetryTemplateTests {
|
||||
.withMessageMatching("Unable to back off for retryable operation '.+?'")
|
||||
.withCause(interruptedException)
|
||||
.satisfies(throwable -> assertThat(throwable.getSuppressed()).containsExactly(exception))
|
||||
// TODO Fix retry count for InterruptedException scenario.
|
||||
// Retry count should actually be 0.
|
||||
.satisfies(throwable -> assertThat(throwable.getRetryCount()).isEqualTo(1))
|
||||
.satisfies(throwable -> assertThat(throwable.getRetryCount()).isZero())
|
||||
.satisfies(throwable -> inOrder.verify(retryListener).onRetryPolicyInterruption(retryPolicy, retryable, throwable));
|
||||
|
||||
verifyNoMoreInteractions(retryListener);
|
||||
|
||||
Reference in New Issue
Block a user