@@ -87,29 +87,6 @@ void withMaxAttempts() {
87
87
assertThat (backOff .getInterval ()).isEqualTo (1000 );
88
88
});
89
89
}
90
-
91
- @ Test
92
- void withMaxElapsedTimePreconditions () {
93
- assertThatIllegalArgumentException ()
94
- .isThrownBy (() -> RetryPolicy .withMaxElapsedTime (Duration .ofMillis (0 )))
95
- .withMessage ("Invalid duration (0ms): maxElapsedTime must be positive." );
96
- assertThatIllegalArgumentException ()
97
- .isThrownBy (() -> RetryPolicy .withMaxElapsedTime (Duration .ofMillis (-1 )))
98
- .withMessage ("Invalid duration (-1ms): maxElapsedTime must be positive." );
99
- }
100
-
101
- @ Test
102
- void withMaxElapsedTime () {
103
- var policy = RetryPolicy .withMaxElapsedTime (Duration .ofMillis (42 ));
104
-
105
- assertThat (policy .shouldRetry (new AssertionError ())).isTrue ();
106
- assertThat (policy .shouldRetry (new IOException ())).isTrue ();
107
-
108
- assertThat (policy .getBackOff ())
109
- .asInstanceOf (type (ExponentialBackOff .class ))
110
- .satisfies (hasDefaultMaxAttemptsAndDelay ())
111
- .extracting (ExponentialBackOff ::getMaxElapsedTime ).isEqualTo (42L );
112
- }
113
90
}
114
91
115
92
@@ -122,7 +99,7 @@ void backOffPlusConflictingConfig() {
122
99
.isThrownBy (() -> RetryPolicy .builder ().backOff (mock ()).delay (Duration .ofMillis (10 )).build ())
123
100
.withMessage ("""
124
101
The following configuration options are not supported with a custom BackOff strategy: \
125
- maxAttempts, delay, jitter, multiplier, maxDelay, or maxElapsedTime .""" );
102
+ maxAttempts, delay, jitter, multiplier, or maxDelay .""" );
126
103
}
127
104
128
105
@ Test
@@ -157,7 +134,7 @@ void maxAttempts() {
157
134
assertThat (backOff .getInitialInterval ()).isEqualTo (1000 );
158
135
});
159
136
160
- assertToString (policy , 1000 , 0 , 1 , Long . MAX_VALUE , Long .MAX_VALUE , 5 );
137
+ assertToString (policy , 1000 , 0 , 1.0 , Long .MAX_VALUE , 5 );
161
138
}
162
139
163
140
@ Test
@@ -178,7 +155,7 @@ void delay() {
178
155
assertThat (backOff .getMaxAttempts ()).isEqualTo (3 );
179
156
});
180
157
181
- assertToString (policy , 42 , 0 , 1 , Long . MAX_VALUE , Long .MAX_VALUE , 3 );
158
+ assertToString (policy , 42 , 0 , 1.0 , Long .MAX_VALUE , 3 );
182
159
}
183
160
184
161
@ Test
@@ -197,7 +174,7 @@ void jitter() {
197
174
.satisfies (hasDefaultMaxAttemptsAndDelay ())
198
175
.extracting (ExponentialBackOff ::getJitter ).isEqualTo (42L );
199
176
200
- assertToString (policy , 1000 , 42 , 1 , Long . MAX_VALUE , Long .MAX_VALUE , 3 );
177
+ assertToString (policy , 1000 , 42 , 1.0 , Long .MAX_VALUE , 3 );
201
178
}
202
179
203
180
@ Test
@@ -226,7 +203,7 @@ void multiplier() {
226
203
.satisfies (hasDefaultMaxAttemptsAndDelay ())
227
204
.extracting (ExponentialBackOff ::getMultiplier ).isEqualTo (1.5 );
228
205
229
- assertToString (policy , 1000 , 0 , 1.5 , Long .MAX_VALUE , Long . MAX_VALUE , 3 );
206
+ assertToString (policy , 1000 , 0 , 1.5 , Long .MAX_VALUE , 3 );
230
207
}
231
208
232
209
@ Test
@@ -248,29 +225,7 @@ void maxDelay() {
248
225
.satisfies (hasDefaultMaxAttemptsAndDelay ())
249
226
.extracting (ExponentialBackOff ::getMaxInterval ).isEqualTo (42L );
250
227
251
- assertToString (policy , 1000 , 0 , 1 , 42 , Long .MAX_VALUE , 3 );
252
- }
253
-
254
- @ Test
255
- void maxElapsedTimePreconditions () {
256
- assertThatIllegalArgumentException ()
257
- .isThrownBy (() -> RetryPolicy .builder ().maxElapsedTime (Duration .ofMillis (0 )))
258
- .withMessage ("Invalid duration (0ms): maxElapsedTime must be positive." );
259
- assertThatIllegalArgumentException ()
260
- .isThrownBy (() -> RetryPolicy .builder ().maxElapsedTime (Duration .ofMillis (-1 )))
261
- .withMessage ("Invalid duration (-1ms): maxElapsedTime must be positive." );
262
- }
263
-
264
- @ Test
265
- void maxElapsedTime () {
266
- var policy = RetryPolicy .builder ().maxElapsedTime (Duration .ofMillis (42 )).build ();
267
-
268
- assertThat (policy .getBackOff ())
269
- .asInstanceOf (type (ExponentialBackOff .class ))
270
- .satisfies (hasDefaultMaxAttemptsAndDelay ())
271
- .extracting (ExponentialBackOff ::getMaxElapsedTime ).isEqualTo (42L );
272
-
273
- assertToString (policy , 1000 , 0 , 1 , Long .MAX_VALUE , 42 , 3 );
228
+ assertToString (policy , 1000 , 0 , 1.0 , 42 , 3 );
274
229
}
275
230
276
231
@ Test
@@ -294,7 +249,7 @@ void includes() {
294
249
295
250
String filters = "includes=" + names (FileNotFoundException .class , IllegalArgumentException .class ,
296
251
NumberFormatException .class , AssertionError .class ) + ", " ;
297
- assertToString (policy , filters , 1000 , 0 , 1 , Long . MAX_VALUE , Long .MAX_VALUE , 3 );
252
+ assertToString (policy , filters , 1000 , 0 , 1.0 , Long .MAX_VALUE , 3 );
298
253
}
299
254
300
255
@ Test
@@ -311,7 +266,7 @@ void includesSubtypeMatching() {
311
266
.asInstanceOf (type (ExponentialBackOff .class ))
312
267
.satisfies (hasDefaultMaxAttemptsAndDelay ());
313
268
314
- assertToString (policy , "includes=[java.io.IOException], " , 1000 , 0 , 1 , Long . MAX_VALUE , Long .MAX_VALUE , 3 );
269
+ assertToString (policy , "includes=[java.io.IOException], " , 1000 , 0 , 1.0 , Long .MAX_VALUE , 3 );
315
270
}
316
271
317
272
@ Test
@@ -335,7 +290,7 @@ void excludes() {
335
290
336
291
String filters = "excludes=" + names (FileNotFoundException .class , IllegalArgumentException .class ,
337
292
NumberFormatException .class , AssertionError .class ) + ", " ;
338
- assertToString (policy , filters , 1000 , 0 , 1 , Long . MAX_VALUE , Long .MAX_VALUE , 3 );
293
+ assertToString (policy , filters , 1000 , 0 , 1.0 , Long .MAX_VALUE , 3 );
339
294
}
340
295
341
296
@ Test
@@ -349,7 +304,7 @@ void excludesSubtypeMatching() {
349
304
assertThat (policy .shouldRetry (new Throwable ())).isTrue ();
350
305
assertThat (policy .shouldRetry (new AssertionError ())).isTrue ();
351
306
352
- assertToString (policy , "excludes=[java.io.IOException], " , 1000 , 0 , 1 , Long . MAX_VALUE , Long .MAX_VALUE , 3 );
307
+ assertToString (policy , "excludes=[java.io.IOException], " , 1000 , 0 , 1.0 , Long .MAX_VALUE , 3 );
353
308
}
354
309
355
310
@ Test
@@ -368,8 +323,7 @@ void predicate() {
368
323
.asInstanceOf (type (ExponentialBackOff .class ))
369
324
.satisfies (hasDefaultMaxAttemptsAndDelay ());
370
325
371
- assertToString (policy , "predicate=NumberFormatExceptionMatcher, " ,
372
- 1000 , 0 , 1 , Long .MAX_VALUE , Long .MAX_VALUE , 3 );
326
+ assertToString (policy , "predicate=NumberFormatExceptionMatcher, " , 1000 , 0 , 1.0 , Long .MAX_VALUE , 3 );
373
327
}
374
328
375
329
@ Test
@@ -398,13 +352,13 @@ void predicatesCombined() {
398
352
399
353
400
354
private static void assertToString (RetryPolicy policy , long initialInterval , long jitter ,
401
- double multiplier , long maxInterval , long maxElapsedTime , int maxAttempts ) {
355
+ double multiplier , long maxInterval , int maxAttempts ) {
402
356
403
- assertToString (policy , "" , initialInterval , jitter , multiplier , maxInterval , maxElapsedTime , maxAttempts );
357
+ assertToString (policy , "" , initialInterval , jitter , multiplier , maxInterval , maxAttempts );
404
358
}
405
359
406
360
private static void assertToString (RetryPolicy policy , String filters , long initialInterval , long jitter ,
407
- double multiplier , long maxInterval , long maxElapsedTime , int maxAttempts ) {
361
+ double multiplier , long maxInterval , int maxAttempts ) {
408
362
409
363
assertThat (policy ).asString ()
410
364
.isEqualTo ("""
@@ -416,7 +370,7 @@ private static void assertToString(RetryPolicy policy, String filters, long init
416
370
maxElapsedTime=%d, \
417
371
maxAttempts=%d\
418
372
]]""" ,
419
- filters , initialInterval , jitter , multiplier , maxInterval , maxElapsedTime , maxAttempts );
373
+ filters , initialInterval , jitter , multiplier , maxInterval , Long . MAX_VALUE , maxAttempts );
420
374
}
421
375
422
376
@ SafeVarargs
0 commit comments