File tree Expand file tree Collapse file tree 2 files changed +3
-6
lines changed
main/java/org/springframework/core/retry
test/java/org/springframework/core/retry Expand file tree Collapse file tree 2 files changed +3
-6
lines changed Original file line number Diff line number Diff line change 19
19
import java .time .Duration ;
20
20
import java .util .ArrayDeque ;
21
21
import java .util .Deque ;
22
- import java .util .Iterator ;
23
22
24
23
import org .jspecify .annotations .Nullable ;
25
24
@@ -203,9 +202,7 @@ public void setRetryListener(RetryListener retryListener) {
203
202
RetryException finalException = new RetryException (
204
203
"Retry policy for operation '%s' exhausted; aborting execution" .formatted (retryableName ),
205
204
exceptions .removeLast ());
206
- for (Iterator <Throwable > it = exceptions .descendingIterator (); it .hasNext ();) {
207
- finalException .addSuppressed (it .next ());
208
- }
205
+ exceptions .forEach (finalException ::addSuppressed );
209
206
this .retryListener .onRetryPolicyExhaustion (retryExecution , finalException );
210
207
throw finalException ;
211
208
}
Original file line number Diff line number Diff line change @@ -178,8 +178,8 @@ public String getName() {
178
178
.withMessage ("Retry policy for operation 'test' exhausted; aborting execution" )
179
179
.withCauseExactlyInstanceOf (IllegalStateException .class )
180
180
.satisfies (hasSuppressedExceptionsSatisfyingExactly (
181
- suppressed1 -> assertThat (suppressed1 ).isExactlyInstanceOf (IOException .class ),
182
- suppressed2 -> assertThat (suppressed2 ).isExactlyInstanceOf (FileNotFoundException .class )
181
+ suppressed1 -> assertThat (suppressed1 ).isExactlyInstanceOf (FileNotFoundException .class ),
182
+ suppressed2 -> assertThat (suppressed2 ).isExactlyInstanceOf (IOException .class )
183
183
));
184
184
// 3 = 1 initial invocation + 2 retry attempts
185
185
assertThat (invocationCount ).hasValue (3 );
You can’t perform that action at this time.
0 commit comments