Use Duration.ZERO whenever possible
This commit is contained in:
parent
58061ae295
commit
c6a8df4a9d
|
@ -52,7 +52,7 @@ public record MethodRetrySpec(
|
||||||
Duration maxDelay) {
|
Duration maxDelay) {
|
||||||
|
|
||||||
public MethodRetrySpec(MethodRetryPredicate predicate, long maxAttempts, Duration delay) {
|
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,
|
public MethodRetrySpec(MethodRetryPredicate predicate, long maxAttempts, Duration delay,
|
||||||
|
|
|
@ -90,7 +90,7 @@ class ScheduledTaskTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void singleExecutionShouldNotHaveNextExecution() {
|
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);
|
Awaitility.await().atMost(Duration.ofSeconds(5)).until(() -> countingRunnable.executionCount > 0);
|
||||||
assertThat(scheduledTask.nextExecution()).isNull();
|
assertThat(scheduledTask.nextExecution()).isNull();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class MaxAttemptsRetryPolicyTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void maxAttempts() {
|
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 backOffExecution = retryPolicy.getBackOff().start();
|
||||||
var throwable = mock(Throwable.class);
|
var throwable = mock(Throwable.class);
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ class RetryPolicyTests {
|
||||||
@Test
|
@Test
|
||||||
void maxDelayPreconditions() {
|
void maxDelayPreconditions() {
|
||||||
assertThatIllegalArgumentException()
|
assertThatIllegalArgumentException()
|
||||||
.isThrownBy(() -> RetryPolicy.builder().maxDelay(Duration.ofMillis(0)))
|
.isThrownBy(() -> RetryPolicy.builder().maxDelay(Duration.ZERO))
|
||||||
.withMessage("Invalid duration (0ms): maxDelay must be positive.");
|
.withMessage("Invalid duration (0ms): maxDelay must be positive.");
|
||||||
assertThatIllegalArgumentException()
|
assertThatIllegalArgumentException()
|
||||||
.isThrownBy(() -> RetryPolicy.builder().maxDelay(Duration.ofMillis(-1)))
|
.isThrownBy(() -> RetryPolicy.builder().maxDelay(Duration.ofMillis(-1)))
|
||||||
|
|
|
@ -51,7 +51,7 @@ class RetryTemplateTests {
|
||||||
void configureRetryTemplate() {
|
void configureRetryTemplate() {
|
||||||
var retryPolicy = RetryPolicy.builder()
|
var retryPolicy = RetryPolicy.builder()
|
||||||
.maxAttempts(3)
|
.maxAttempts(3)
|
||||||
.delay(Duration.ofMillis(0))
|
.delay(Duration.ZERO)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
retryTemplate.setRetryPolicy(retryPolicy);
|
retryTemplate.setRetryPolicy(retryPolicy);
|
||||||
|
@ -171,7 +171,7 @@ class RetryTemplateTests {
|
||||||
|
|
||||||
var retryPolicy = RetryPolicy.builder()
|
var retryPolicy = RetryPolicy.builder()
|
||||||
.maxAttempts(Integer.MAX_VALUE)
|
.maxAttempts(Integer.MAX_VALUE)
|
||||||
.delay(Duration.ofMillis(0))
|
.delay(Duration.ZERO)
|
||||||
.includes(IOException.class)
|
.includes(IOException.class)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -194,13 +194,13 @@ class RetryTemplateTests {
|
||||||
argumentSet("Excludes",
|
argumentSet("Excludes",
|
||||||
RetryPolicy.builder()
|
RetryPolicy.builder()
|
||||||
.maxAttempts(Integer.MAX_VALUE)
|
.maxAttempts(Integer.MAX_VALUE)
|
||||||
.delay(Duration.ofMillis(0))
|
.delay(Duration.ZERO)
|
||||||
.excludes(FileNotFoundException.class)
|
.excludes(FileNotFoundException.class)
|
||||||
.build()),
|
.build()),
|
||||||
argumentSet("Includes & Excludes",
|
argumentSet("Includes & Excludes",
|
||||||
RetryPolicy.builder()
|
RetryPolicy.builder()
|
||||||
.maxAttempts(Integer.MAX_VALUE)
|
.maxAttempts(Integer.MAX_VALUE)
|
||||||
.delay(Duration.ofMillis(0))
|
.delay(Duration.ZERO)
|
||||||
.includes(IOException.class)
|
.includes(IOException.class)
|
||||||
.excludes(FileNotFoundException.class)
|
.excludes(FileNotFoundException.class)
|
||||||
.build())
|
.build())
|
||||||
|
|
|
@ -76,11 +76,11 @@ public class LeakAwareDataBufferFactory implements DataBufferFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether all the data buffers allocated by this factory have also been released.
|
* 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.
|
* method.
|
||||||
*/
|
*/
|
||||||
public void checkForLeaks() {
|
public void checkForLeaks() {
|
||||||
checkForLeaks(Duration.ofSeconds(0));
|
checkForLeaks(Duration.ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -71,7 +71,7 @@ class DispatcherHandlerTests {
|
||||||
context.refresh();
|
context.refresh();
|
||||||
|
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/"));
|
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");
|
assertThat(exchange.getResponse().getBodyAsString().block(Duration.ofSeconds(5))).isEqualTo("1");
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ class DispatcherHandlerTests {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(request);
|
MockServerWebExchange exchange = MockServerWebExchange.from(request);
|
||||||
new DispatcherHandler(context).handle(exchange).block(Duration.ofSeconds(0));
|
new DispatcherHandler(context).handle(exchange).block(Duration.ZERO);
|
||||||
|
|
||||||
verifyNoInteractions(webHandler);
|
verifyNoInteractions(webHandler);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ class RequestParamMapMethodArgumentResolverTests {
|
||||||
|
|
||||||
|
|
||||||
private Object resolve(MethodParameter parameter, ServerWebExchange exchange) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue