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() {
46
46
47
47
/**
48
48
* 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.
50
50
*/
51
51
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 );
53
54
}
54
55
55
56
/**
Original file line number Diff line number Diff line change 17
17
package org .springframework .core .retry .support ;
18
18
19
19
import org .junit .jupiter .api .Test ;
20
- import org .mockito .Mockito ;
21
20
22
21
import org .springframework .core .retry .RetryExecution ;
23
22
24
23
import static org .assertj .core .api .Assertions .assertThat ;
25
24
import static org .assertj .core .api .Assertions .assertThatThrownBy ;
25
+ import static org .mockito .Mockito .mock ;
26
26
27
27
/**
28
28
* Tests for {@link MaxRetryAttemptsPolicy}.
@@ -35,15 +35,16 @@ class MaxRetryAttemptsPolicyTests {
35
35
void testDefaultMaxRetryAttempts () {
36
36
// given
37
37
MaxRetryAttemptsPolicy retryPolicy = new MaxRetryAttemptsPolicy ();
38
+ Throwable throwable = mock ();
38
39
39
40
// when
40
41
RetryExecution retryExecution = retryPolicy .start ();
41
42
42
43
// 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 ();
47
48
}
48
49
49
50
@ Test
You can’t perform that action at this time.
0 commit comments