File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
main/java/org/springframework/core/retry/support
test/java/org/springframework/core/retry/support Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -46,10 +46,11 @@ public CompositeRetryListener() {
4646
4747 /**
4848 * Create a new {@link CompositeRetryListener} with a list of delegates.
49- * @param listeners the delegate listeners to register
49+ * @param listeners the delegate listeners to register. Must not be empty.
5050 */
5151 public CompositeRetryListener (List <RetryListener > listeners ) {
52- this .listeners = listeners ;
52+ Assert .notEmpty (listeners , "RetryListener List must not be empty" );
53+ this .listeners = List .copyOf (listeners );
5354 }
5455
5556 /**
Original file line number Diff line number Diff line change 1717package org .springframework .core .retry .support ;
1818
1919import org .junit .jupiter .api .Test ;
20- import org .mockito .Mockito ;
2120
2221import org .springframework .core .retry .RetryExecution ;
2322
2423import static org .assertj .core .api .Assertions .assertThat ;
2524import static org .assertj .core .api .Assertions .assertThatThrownBy ;
25+ import static org .mockito .Mockito .mock ;
2626
2727/**
2828 * Tests for {@link MaxRetryAttemptsPolicy}.
@@ -35,15 +35,16 @@ class MaxRetryAttemptsPolicyTests {
3535 void testDefaultMaxRetryAttempts () {
3636 // given
3737 MaxRetryAttemptsPolicy retryPolicy = new MaxRetryAttemptsPolicy ();
38+ Throwable throwable = mock ();
3839
3940 // when
4041 RetryExecution retryExecution = retryPolicy .start ();
4142
4243 // then
43- assertThat (retryExecution .shouldRetry (Mockito . any ( Exception . class ) )).isTrue ();
44- assertThat (retryExecution .shouldRetry (Mockito . any ( Exception . class ) )).isTrue ();
45- assertThat (retryExecution .shouldRetry (Mockito . any ( Exception . class ) )).isTrue ();
46- assertThat (retryExecution .shouldRetry (Mockito . any ( Exception . class ) )).isFalse ();
44+ assertThat (retryExecution .shouldRetry (throwable )).isTrue ();
45+ assertThat (retryExecution .shouldRetry (throwable )).isTrue ();
46+ assertThat (retryExecution .shouldRetry (throwable )).isTrue ();
47+ assertThat (retryExecution .shouldRetry (throwable )).isFalse ();
4748 }
4849
4950 @ Test
You can’t perform that action at this time.
0 commit comments