Skip to content

Commit c6a8df4

Browse files
committed
Use Duration.ZERO whenever possible
1 parent 58061ae commit c6a8df4

File tree

8 files changed

+13
-13
lines changed

8 files changed

+13
-13
lines changed

spring-context/src/main/java/org/springframework/resilience/retry/MethodRetrySpec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public record MethodRetrySpec(
5252
Duration maxDelay) {
5353

5454
public MethodRetrySpec(MethodRetryPredicate predicate, long maxAttempts, Duration delay) {
55-
this(predicate, maxAttempts, delay, Duration.ofMillis(0), 1.0, Duration.ofMillis(Long.MAX_VALUE));
55+
this(predicate, maxAttempts, delay, Duration.ZERO, 1.0, Duration.ofMillis(Long.MAX_VALUE));
5656
}
5757

5858
public MethodRetrySpec(MethodRetryPredicate predicate, long maxAttempts, Duration delay,

spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTaskTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void cancelledTaskShouldNotHaveNextExecution() {
9090

9191
@Test
9292
void singleExecutionShouldNotHaveNextExecution() {
93-
ScheduledTask scheduledTask = taskRegistrar.scheduleOneTimeTask(new OneTimeTask(countingRunnable, Duration.ofSeconds(0)));
93+
ScheduledTask scheduledTask = taskRegistrar.scheduleOneTimeTask(new OneTimeTask(countingRunnable, Duration.ZERO));
9494
Awaitility.await().atMost(Duration.ofSeconds(5)).until(() -> countingRunnable.executionCount > 0);
9595
assertThat(scheduledTask.nextExecution()).isNull();
9696
}

spring-core/src/test/java/org/springframework/core/retry/MaxAttemptsRetryPolicyTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class MaxAttemptsRetryPolicyTests {
3939

4040
@Test
4141
void maxAttempts() {
42-
var retryPolicy = RetryPolicy.builder().maxAttempts(2).delay(Duration.ofMillis(0)).build();
42+
var retryPolicy = RetryPolicy.builder().maxAttempts(2).delay(Duration.ZERO).build();
4343
var backOffExecution = retryPolicy.getBackOff().start();
4444
var throwable = mock(Throwable.class);
4545

spring-core/src/test/java/org/springframework/core/retry/RetryPolicyTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void multiplier() {
209209
@Test
210210
void maxDelayPreconditions() {
211211
assertThatIllegalArgumentException()
212-
.isThrownBy(() -> RetryPolicy.builder().maxDelay(Duration.ofMillis(0)))
212+
.isThrownBy(() -> RetryPolicy.builder().maxDelay(Duration.ZERO))
213213
.withMessage("Invalid duration (0ms): maxDelay must be positive.");
214214
assertThatIllegalArgumentException()
215215
.isThrownBy(() -> RetryPolicy.builder().maxDelay(Duration.ofMillis(-1)))

spring-core/src/test/java/org/springframework/core/retry/RetryTemplateTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class RetryTemplateTests {
5151
void configureRetryTemplate() {
5252
var retryPolicy = RetryPolicy.builder()
5353
.maxAttempts(3)
54-
.delay(Duration.ofMillis(0))
54+
.delay(Duration.ZERO)
5555
.build();
5656

5757
retryTemplate.setRetryPolicy(retryPolicy);
@@ -171,7 +171,7 @@ public String getName() {
171171

172172
var retryPolicy = RetryPolicy.builder()
173173
.maxAttempts(Integer.MAX_VALUE)
174-
.delay(Duration.ofMillis(0))
174+
.delay(Duration.ZERO)
175175
.includes(IOException.class)
176176
.build();
177177

@@ -194,13 +194,13 @@ public String getName() {
194194
argumentSet("Excludes",
195195
RetryPolicy.builder()
196196
.maxAttempts(Integer.MAX_VALUE)
197-
.delay(Duration.ofMillis(0))
197+
.delay(Duration.ZERO)
198198
.excludes(FileNotFoundException.class)
199199
.build()),
200200
argumentSet("Includes & Excludes",
201201
RetryPolicy.builder()
202202
.maxAttempts(Integer.MAX_VALUE)
203-
.delay(Duration.ofMillis(0))
203+
.delay(Duration.ZERO)
204204
.includes(IOException.class)
205205
.excludes(FileNotFoundException.class)
206206
.build())

spring-core/src/testFixtures/java/org/springframework/core/testfixture/io/buffer/LeakAwareDataBufferFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ public LeakAwareDataBufferFactory(DataBufferFactory delegate) {
7676

7777
/**
7878
* Checks whether all the data buffers allocated by this factory have also been released.
79-
* If not, then an {@link AssertionError} is thrown. Typically used from a JUnit <em>after</em>
79+
* <p>If not, then an {@link AssertionError} is thrown. Typically used from a JUnit <em>after</em>
8080
* method.
8181
*/
8282
public void checkForLeaks() {
83-
checkForLeaks(Duration.ofSeconds(0));
83+
checkForLeaks(Duration.ZERO);
8484
}
8585

8686
/**

spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void handlerMappingOrder() {
7171
context.refresh();
7272

7373
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/"));
74-
new DispatcherHandler(context).handle(exchange).block(Duration.ofSeconds(0));
74+
new DispatcherHandler(context).handle(exchange).block(Duration.ZERO);
7575

7676
assertThat(exchange.getResponse().getBodyAsString().block(Duration.ofSeconds(5))).isEqualTo("1");
7777
}
@@ -94,7 +94,7 @@ void preFlightRequest() {
9494
.build();
9595

9696
MockServerWebExchange exchange = MockServerWebExchange.from(request);
97-
new DispatcherHandler(context).handle(exchange).block(Duration.ofSeconds(0));
97+
new DispatcherHandler(context).handle(exchange).block(Duration.ZERO);
9898

9999
verifyNoInteractions(webHandler);
100100
}

spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolverTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void resolveMultiValueMapArgument() {
9191

9292

9393
private Object resolve(MethodParameter parameter, ServerWebExchange exchange) {
94-
return this.resolver.resolveArgument(parameter, null, exchange).block(Duration.ofMillis(0));
94+
return this.resolver.resolveArgument(parameter, null, exchange).block(Duration.ZERO);
9595
}
9696

9797

0 commit comments

Comments
 (0)