mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-30 19:29:02 +00:00
Use Duration.ZERO whenever possible
This commit is contained in:
+1
-1
@@ -52,7 +52,7 @@ public record MethodRetrySpec(
|
||||
Duration maxDelay) {
|
||||
|
||||
public MethodRetrySpec(MethodRetryPredicate predicate, long maxAttempts, Duration delay) {
|
||||
this(predicate, maxAttempts, delay, Duration.ofMillis(0), 1.0, Duration.ofMillis(Long.MAX_VALUE));
|
||||
this(predicate, maxAttempts, delay, Duration.ZERO, 1.0, Duration.ofMillis(Long.MAX_VALUE));
|
||||
}
|
||||
|
||||
public MethodRetrySpec(MethodRetryPredicate predicate, long maxAttempts, Duration delay,
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ class ScheduledTaskTests {
|
||||
|
||||
@Test
|
||||
void singleExecutionShouldNotHaveNextExecution() {
|
||||
ScheduledTask scheduledTask = taskRegistrar.scheduleOneTimeTask(new OneTimeTask(countingRunnable, Duration.ofSeconds(0)));
|
||||
ScheduledTask scheduledTask = taskRegistrar.scheduleOneTimeTask(new OneTimeTask(countingRunnable, Duration.ZERO));
|
||||
Awaitility.await().atMost(Duration.ofSeconds(5)).until(() -> countingRunnable.executionCount > 0);
|
||||
assertThat(scheduledTask.nextExecution()).isNull();
|
||||
}
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ class MaxAttemptsRetryPolicyTests {
|
||||
|
||||
@Test
|
||||
void maxAttempts() {
|
||||
var retryPolicy = RetryPolicy.builder().maxAttempts(2).delay(Duration.ofMillis(0)).build();
|
||||
var retryPolicy = RetryPolicy.builder().maxAttempts(2).delay(Duration.ZERO).build();
|
||||
var backOffExecution = retryPolicy.getBackOff().start();
|
||||
var throwable = mock(Throwable.class);
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ class RetryPolicyTests {
|
||||
@Test
|
||||
void maxDelayPreconditions() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> RetryPolicy.builder().maxDelay(Duration.ofMillis(0)))
|
||||
.isThrownBy(() -> RetryPolicy.builder().maxDelay(Duration.ZERO))
|
||||
.withMessage("Invalid duration (0ms): maxDelay must be positive.");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> RetryPolicy.builder().maxDelay(Duration.ofMillis(-1)))
|
||||
|
||||
@@ -51,7 +51,7 @@ class RetryTemplateTests {
|
||||
void configureRetryTemplate() {
|
||||
var retryPolicy = RetryPolicy.builder()
|
||||
.maxAttempts(3)
|
||||
.delay(Duration.ofMillis(0))
|
||||
.delay(Duration.ZERO)
|
||||
.build();
|
||||
|
||||
retryTemplate.setRetryPolicy(retryPolicy);
|
||||
@@ -171,7 +171,7 @@ class RetryTemplateTests {
|
||||
|
||||
var retryPolicy = RetryPolicy.builder()
|
||||
.maxAttempts(Integer.MAX_VALUE)
|
||||
.delay(Duration.ofMillis(0))
|
||||
.delay(Duration.ZERO)
|
||||
.includes(IOException.class)
|
||||
.build();
|
||||
|
||||
@@ -194,13 +194,13 @@ class RetryTemplateTests {
|
||||
argumentSet("Excludes",
|
||||
RetryPolicy.builder()
|
||||
.maxAttempts(Integer.MAX_VALUE)
|
||||
.delay(Duration.ofMillis(0))
|
||||
.delay(Duration.ZERO)
|
||||
.excludes(FileNotFoundException.class)
|
||||
.build()),
|
||||
argumentSet("Includes & Excludes",
|
||||
RetryPolicy.builder()
|
||||
.maxAttempts(Integer.MAX_VALUE)
|
||||
.delay(Duration.ofMillis(0))
|
||||
.delay(Duration.ZERO)
|
||||
.includes(IOException.class)
|
||||
.excludes(FileNotFoundException.class)
|
||||
.build())
|
||||
|
||||
+2
-2
@@ -76,11 +76,11 @@ public class LeakAwareDataBufferFactory implements DataBufferFactory {
|
||||
|
||||
/**
|
||||
* Checks whether all the data buffers allocated by this factory have also been released.
|
||||
* If not, then an {@link AssertionError} is thrown. Typically used from a JUnit <em>after</em>
|
||||
* <p>If not, then an {@link AssertionError} is thrown. Typically used from a JUnit <em>after</em>
|
||||
* method.
|
||||
*/
|
||||
public void checkForLeaks() {
|
||||
checkForLeaks(Duration.ofSeconds(0));
|
||||
checkForLeaks(Duration.ZERO);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -71,7 +71,7 @@ class DispatcherHandlerTests {
|
||||
context.refresh();
|
||||
|
||||
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/"));
|
||||
new DispatcherHandler(context).handle(exchange).block(Duration.ofSeconds(0));
|
||||
new DispatcherHandler(context).handle(exchange).block(Duration.ZERO);
|
||||
|
||||
assertThat(exchange.getResponse().getBodyAsString().block(Duration.ofSeconds(5))).isEqualTo("1");
|
||||
}
|
||||
@@ -94,7 +94,7 @@ class DispatcherHandlerTests {
|
||||
.build();
|
||||
|
||||
MockServerWebExchange exchange = MockServerWebExchange.from(request);
|
||||
new DispatcherHandler(context).handle(exchange).block(Duration.ofSeconds(0));
|
||||
new DispatcherHandler(context).handle(exchange).block(Duration.ZERO);
|
||||
|
||||
verifyNoInteractions(webHandler);
|
||||
}
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ class RequestParamMapMethodArgumentResolverTests {
|
||||
|
||||
|
||||
private Object resolve(MethodParameter parameter, ServerWebExchange exchange) {
|
||||
return this.resolver.resolveArgument(parameter, null, exchange).block(Duration.ofMillis(0));
|
||||
return this.resolver.resolveArgument(parameter, null, exchange).block(Duration.ZERO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user