From 53f7269af361974afeabf123dbf96607bb48d2d1 Mon Sep 17 00:00:00 2001 From: Qi Tan <16416018+TQJADE@users.noreply.github.com> Date: Tue, 13 Oct 2026 21:37:55 -0700 Subject: [PATCH] GenericRetry refactor --- .../documentation/error-handling-retries.md | 14 +- docs/content/en/docs/documentation/testing.md | 2 +- .../processing/retry/GenericRetry.java | 149 +++++++++++++++++- .../processing/event/EventProcessorTest.java | 22 +-- .../event/ReconciliationDispatcherTest.java | 2 +- .../retry/GenericRetryExecutionTest.java | 27 ++-- .../processing/retry/GenericRetryTest.java | 104 ++++++++++++ .../operator/config/loader/ConfigLoader.java | 12 +- .../ErrorStatusHandlerIT.java | 3 +- .../operator/baseapi/retry/RetryIT.java | 7 +- ...etryIntervalHonoredOnFrequentEventsIT.java | 7 +- .../baseapi/retry/RetryMaxAttemptIT.java | 7 +- .../TriggerReconcilerOnAllEventIT.java | 9 +- 13 files changed, 311 insertions(+), 54 deletions(-) create mode 100644 operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/retry/GenericRetryTest.java diff --git a/docs/content/en/docs/documentation/error-handling-retries.md b/docs/content/en/docs/documentation/error-handling-retries.md index 428c35b9ae..fe60334fd3 100644 --- a/docs/content/en/docs/documentation/error-handling-retries.md +++ b/docs/content/en/docs/documentation/error-handling-retries.md @@ -12,12 +12,18 @@ JOSDK automatically schedules retries whenever your `Reconciler` throws an excep The default retry implementation covers most typical use cases with exponential backoff: ```java -GenericRetry.defaultLimitedExponentialRetry() - .setInitialInterval(5000) // Start with 5-second delay - .setIntervalMultiplier(1.5D) // Increase delay by 1.5x each retry - .setMaxAttempts(5); // Maximum 5 attempts +GenericRetry.builder() + .withInitialInterval(Duration.ofSeconds(5)) // Start with 5-second delay + .withIntervalMultiplier(1.5D) // Increase delay by 1.5x each retry + .withMaxAttempts(5) // Maximum 5 attempts + .withMaxInterval(Duration.ofMinutes(1)) // Cap the delay at 1 minute + .build(); ``` +Prefer the builder for creating `GenericRetry` instances, and use `toBuilder()` to derive a variant +of an existing configuration. The `set*` methods are deprecated and will be removed in a future +major version, at which point `GenericRetry` becomes immutable. + ### Configuration Options **Using the `@GradualRetry` annotation:** diff --git a/docs/content/en/docs/documentation/testing.md b/docs/content/en/docs/documentation/testing.md index 271a2d1dc7..9a74a5376f 100644 --- a/docs/content/en/docs/documentation/testing.md +++ b/docs/content/en/docs/documentation/testing.md @@ -117,7 +117,7 @@ LocallyRunOperatorExtension.builder() // Override controller configuration .withReconciler(new MyReconciler(), config -> config .settingNamespace("specific-namespace") - .withRetry(new GenericRetry().withLinearRetry())) + .withRetry(GenericRetry.builder().withLinearRetry().build())) // Pre-deploy infrastructure resources before operator starts .withInfrastructure(configMap, secret) // Register CRDs for resources not managed by a reconciler diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/retry/GenericRetry.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/retry/GenericRetry.java index 5ee016b34f..4c98e5a714 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/retry/GenericRetry.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/retry/GenericRetry.java @@ -32,16 +32,42 @@ public class GenericRetry implements Retry, AnnotationConfigurable @Deprecated(forRemoval = true) public static final Retry DEFAULT = new GenericRetry(); + /** + * Creates an instance with the default values. Prefer {@link #builder()} or {@link + * #defaultLimitedExponentialRetry()}; this constructor is kept public so that the class can be + * instantiated and configured from the {@link GradualRetry} annotation. + */ + public GenericRetry() {} + + private GenericRetry(Builder builder) { + this.maxAttempts = builder.maxAttempts; + this.initialInterval = builder.initialInterval; + this.intervalMultiplier = builder.intervalMultiplier; + this.maxInterval = builder.maxInterval; + } + + public static Builder builder() { + return new Builder(); + } + public static GenericRetry defaultLimitedExponentialRetry() { - return new GenericRetry(); + return builder().build(); } public static GenericRetry noRetry() { - return new GenericRetry().setMaxAttempts(0); + return builder().withMaxAttempts(0).build(); } public static GenericRetry every10second10TimesRetry() { - return new GenericRetry().withLinearRetry().setMaxAttempts(10).setInitialInterval(10000); + return builder() + .withLinearRetry() + .withMaxAttempts(10) + .withInitialInterval(Duration.ofSeconds(10)) + .build(); + } + + public Builder toBuilder() { + return new Builder(this); } @Override @@ -53,6 +79,10 @@ public int getMaxAttempts() { return maxAttempts; } + /** + * @deprecated use {@link Builder#withMaxAttempts(int)} instead + */ + @Deprecated(forRemoval = true) public GenericRetry setMaxAttempts(int maxRetryAttempts) { this.maxAttempts = maxRetryAttempts; return this; @@ -62,11 +92,19 @@ public long getInitialInterval() { return initialInterval; } + /** + * @deprecated use {@link Builder#withInitialInterval(Duration)} instead + */ + @Deprecated(forRemoval = true) public GenericRetry setInitialInterval(Duration initialInterval) { - setInitialInterval(initialInterval.toMillis()); + this.initialInterval = initialInterval.toMillis(); return this; } + /** + * @deprecated use {@link Builder#withInitialInterval(long)} instead + */ + @Deprecated(forRemoval = true) public GenericRetry setInitialInterval(long initialInterval) { this.initialInterval = initialInterval; return this; @@ -76,6 +114,10 @@ public double getIntervalMultiplier() { return intervalMultiplier; } + /** + * @deprecated use {@link Builder#withIntervalMultiplier(double)} instead + */ + @Deprecated(forRemoval = true) public GenericRetry setIntervalMultiplier(double intervalMultiplier) { this.intervalMultiplier = intervalMultiplier; return this; @@ -85,24 +127,46 @@ public long getMaxInterval() { return maxInterval; } + /** + * @deprecated use {@link Builder#withMaxInterval(long)} instead + */ + @Deprecated(forRemoval = true) public GenericRetry setMaxInterval(long maxInterval) { this.maxInterval = maxInterval; return this; } + /** + * @deprecated use {@link Builder#withMaxInterval(Duration)} instead + */ + @Deprecated(forRemoval = true) public GenericRetry setMaxInterval(Duration maxInterval) { - return setMaxInterval(maxInterval.toMillis()); + this.maxInterval = maxInterval.toMillis(); + return this; } + /** + * @deprecated use {@link Builder#withoutMaxInterval()} instead + */ + @Deprecated(forRemoval = true) public GenericRetry withoutMaxInterval() { this.maxInterval = -1; return this; } + /** + * @deprecated use {@link Builder#withoutMaxAttempts()} instead + */ + @Deprecated(forRemoval = true) public GenericRetry withoutMaxAttempts() { - return this.setMaxAttempts(-1); + this.maxAttempts = -1; + return this; } + /** + * @deprecated use {@link Builder#withLinearRetry()} instead + */ + @Deprecated(forRemoval = true) public GenericRetry withLinearRetry() { this.intervalMultiplier = 1; return this; @@ -118,4 +182,77 @@ public void initFrom(GradualRetry configuration) { ? GradualRetry.DEFAULT_MAX_INTERVAL : configuration.maxInterval(); } + + @Override + public String toString() { + return "GenericRetry{maxAttempts=" + + maxAttempts + + ", initialInterval=" + + initialInterval + + ", intervalMultiplier=" + + intervalMultiplier + + ", maxInterval=" + + maxInterval + + '}'; + } + + public static final class Builder { + private int maxAttempts = GradualRetry.DEFAULT_MAX_ATTEMPTS; + private long initialInterval = GradualRetry.DEFAULT_INITIAL_INTERVAL; + private double intervalMultiplier = GradualRetry.DEFAULT_MULTIPLIER; + private long maxInterval = GradualRetry.DEFAULT_MAX_INTERVAL; + + private Builder() {} + + private Builder(GenericRetry retry) { + this.maxAttempts = retry.maxAttempts; + this.initialInterval = retry.initialInterval; + this.intervalMultiplier = retry.intervalMultiplier; + this.maxInterval = retry.maxInterval; + } + + public Builder withMaxAttempts(int maxAttempts) { + this.maxAttempts = maxAttempts; + return this; + } + + public Builder withoutMaxAttempts() { + return withMaxAttempts(-1); + } + + public Builder withInitialInterval(long initialIntervalMillis) { + this.initialInterval = initialIntervalMillis; + return this; + } + + public Builder withInitialInterval(Duration initialInterval) { + return withInitialInterval(initialInterval.toMillis()); + } + + public Builder withIntervalMultiplier(double intervalMultiplier) { + this.intervalMultiplier = intervalMultiplier; + return this; + } + + public Builder withLinearRetry() { + return withIntervalMultiplier(1); + } + + public Builder withMaxInterval(long maxIntervalMillis) { + this.maxInterval = maxIntervalMillis; + return this; + } + + public Builder withMaxInterval(Duration maxInterval) { + return withMaxInterval(maxInterval.toMillis()); + } + + public Builder withoutMaxInterval() { + return withMaxInterval(-1); + } + + public GenericRetry build() { + return new GenericRetry(this); + } + } } diff --git a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/EventProcessorTest.java b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/EventProcessorTest.java index 941da8be4c..4f0d4fb028 100644 --- a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/EventProcessorTest.java +++ b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/EventProcessorTest.java @@ -765,9 +765,7 @@ void processesAdditionalEventWhileInDeleteModeRetry() { spy( new EventProcessor( controllerConfigTriggerAllEvent( - GenericRetry.defaultLimitedExponentialRetry() - .setInitialInterval(1000) - .setMaxAttempts(-1), + GenericRetry.builder().withInitialInterval(1000).withMaxAttempts(-1).build(), rateLimiterMock), reconciliationDispatcherMock, eventSourceManagerMock, @@ -796,10 +794,11 @@ void afterRetryExhaustedAdditionalEventTriggerReconciliationWhenDeleteEventPrese spy( new EventProcessor( controllerConfigTriggerAllEvent( - GenericRetry.defaultLimitedExponentialRetry() - .setInitialInterval(100) - .setIntervalMultiplier(1) - .setMaxAttempts(1), + GenericRetry.builder() + .withInitialInterval(100) + .withIntervalMultiplier(1) + .withMaxAttempts(1) + .build(), rateLimiterMock), reconciliationDispatcherMock, eventSourceManagerMock, @@ -831,10 +830,11 @@ void rateLimitsDeleteEventInAllEventMode() { spy( new EventProcessor( controllerConfigTriggerAllEvent( - GenericRetry.defaultLimitedExponentialRetry() - .setInitialInterval(100) - .setIntervalMultiplier(1) - .setMaxAttempts(1), + GenericRetry.builder() + .withInitialInterval(100) + .withIntervalMultiplier(1) + .withMaxAttempts(1) + .build(), rateLimiterMock), reconciliationDispatcherMock, eventSourceManagerMock, diff --git a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcherTest.java b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcherTest.java index 191836a0dc..ec97054ed4 100644 --- a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcherTest.java +++ b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcherTest.java @@ -595,7 +595,7 @@ void ifRetryLimitedToZeroMaxAttemptsErrorHandlerGetsCorrectLastAttempt() { var configuration = MockControllerConfiguration.forResource( (Class) testCustomResource.getClass()); - when(configuration.getRetry()).thenReturn(new GenericRetry().setMaxAttempts(0)); + when(configuration.getRetry()).thenReturn(GenericRetry.builder().withMaxAttempts(0).build()); reconciliationDispatcher = init(testCustomResource, reconciler, configuration, customResourceFacade, false); diff --git a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/retry/GenericRetryExecutionTest.java b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/retry/GenericRetryExecutionTest.java index 8d7ec55e37..f04ab52abb 100644 --- a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/retry/GenericRetryExecutionTest.java +++ b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/retry/GenericRetryExecutionTest.java @@ -26,7 +26,7 @@ class GenericRetryExecutionTest { @Test void noNextDelayIfMaxAttemptLimitReached() { RetryExecution retryExecution = - GenericRetry.defaultLimitedExponentialRetry().setMaxAttempts(3).initExecution(); + GenericRetry.builder().withMaxAttempts(3).build().initExecution(); Optional res = callNextDelayNTimes(retryExecution, 2); assertThat(res).isNotEmpty(); @@ -37,10 +37,11 @@ void noNextDelayIfMaxAttemptLimitReached() { @Test void canLimitMaxIntervalLength() { RetryExecution retryExecution = - GenericRetry.defaultLimitedExponentialRetry() - .setInitialInterval(2000) - .setMaxInterval(4500) - .setIntervalMultiplier(2) + GenericRetry.builder() + .withInitialInterval(2000) + .withMaxInterval(4500) + .withIntervalMultiplier(2) + .build() .initExecution(); Optional res = callNextDelayNTimes(retryExecution, 4); @@ -56,7 +57,8 @@ void supportsNoRetry() { @Test void supportsIsLastExecution() { - GenericRetryExecution execution = new GenericRetry().setMaxAttempts(2).initExecution(); + GenericRetryExecution execution = + GenericRetry.builder().withMaxAttempts(2).build().initExecution(); assertThat(execution.isLastAttempt()).isFalse(); execution.nextDelay(); @@ -83,7 +85,8 @@ void remainingDurationEmptyBeforeFirstNextDelay() { @Test void remainingDurationPresentAfterNextDelay() { long interval = 60_000L; - RetryExecution retryExecution = new GenericRetry().setInitialInterval(interval).initExecution(); + RetryExecution retryExecution = + GenericRetry.builder().withInitialInterval(interval).build().initExecution(); retryExecution.nextDelay(); @@ -94,7 +97,8 @@ void remainingDurationPresentAfterNextDelay() { @Test void remainingDurationEmptyAfterIntervalElapsed() throws InterruptedException { - RetryExecution retryExecution = new GenericRetry().setInitialInterval(20).initExecution(); + RetryExecution retryExecution = + GenericRetry.builder().withInitialInterval(20).build().initExecution(); retryExecution.nextDelay(); Thread.sleep(60); @@ -107,9 +111,10 @@ void remainingDurationReflectsUpdatedIntervalAfterSubsequentNextDelay() { long initialInterval = 1000L; double multiplier = 2.0; RetryExecution retryExecution = - new GenericRetry() - .setInitialInterval(initialInterval) - .setIntervalMultiplier(multiplier) + GenericRetry.builder() + .withInitialInterval(initialInterval) + .withIntervalMultiplier(multiplier) + .build() .initExecution(); // first two calls keep the initial interval (multiplier only kicks in after attempt 1) diff --git a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/retry/GenericRetryTest.java b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/retry/GenericRetryTest.java new file mode 100644 index 0000000000..f30b372ac7 --- /dev/null +++ b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/retry/GenericRetryTest.java @@ -0,0 +1,104 @@ +/* + * Copyright Java Operator SDK Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.javaoperatorsdk.operator.processing.retry; + +import java.time.Duration; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class GenericRetryTest { + + @Test + void builderUsesDefaults() { + var retry = GenericRetry.builder().build(); + + assertThat(retry.getMaxAttempts()).isEqualTo(GradualRetry.DEFAULT_MAX_ATTEMPTS); + assertThat(retry.getInitialInterval()).isEqualTo(GradualRetry.DEFAULT_INITIAL_INTERVAL); + assertThat(retry.getIntervalMultiplier()).isEqualTo(GradualRetry.DEFAULT_MULTIPLIER); + assertThat(retry.getMaxInterval()).isEqualTo(GradualRetry.DEFAULT_MAX_INTERVAL); + } + + @Test + void builderSetsAllValues() { + var retry = + GenericRetry.builder() + .withMaxAttempts(7) + .withInitialInterval(Duration.ofSeconds(3)) + .withIntervalMultiplier(2.5) + .withMaxInterval(Duration.ofMinutes(1)) + .build(); + + assertThat(retry.getMaxAttempts()).isEqualTo(7); + assertThat(retry.getInitialInterval()).isEqualTo(3000); + assertThat(retry.getIntervalMultiplier()).isEqualTo(2.5); + assertThat(retry.getMaxInterval()).isEqualTo(60_000); + } + + @Test + void builderSupportsUnlimitedAndLinearRetry() { + var retry = + GenericRetry.builder() + .withIntervalMultiplier(3) + .withoutMaxAttempts() + .withoutMaxInterval() + .withLinearRetry() + .build(); + + assertThat(retry.getMaxAttempts()).isEqualTo(-1); + assertThat(retry.getMaxInterval()).isEqualTo(-1); + assertThat(retry.getIntervalMultiplier()).isEqualTo(1); + } + + @Test + void builderCreatesIndependentInstances() { + var builder = GenericRetry.builder().withMaxAttempts(3); + var first = builder.build(); + var second = builder.withMaxAttempts(10).build(); + + assertThat(first.getMaxAttempts()).isEqualTo(3); + assertThat(second.getMaxAttempts()).isEqualTo(10); + } + + @Test + void toBuilderCopiesValuesWithoutModifyingOriginal() { + var original = + GenericRetry.builder() + .withMaxAttempts(4) + .withInitialInterval(100) + .withMaxInterval(500) + .build(); + + var derived = original.toBuilder().withMaxAttempts(8).build(); + + assertThat(original.getMaxAttempts()).isEqualTo(4); + assertThat(derived.getMaxAttempts()).isEqualTo(8); + assertThat(derived.getInitialInterval()).isEqualTo(100); + assertThat(derived.getMaxInterval()).isEqualTo(500); + assertThat(derived.getIntervalMultiplier()).isEqualTo(original.getIntervalMultiplier()); + } + + @Test + void factoryMethods() { + assertThat(GenericRetry.noRetry().getMaxAttempts()).isZero(); + + var every10s = GenericRetry.every10second10TimesRetry(); + assertThat(every10s.getMaxAttempts()).isEqualTo(10); + assertThat(every10s.getInitialInterval()).isEqualTo(10_000); + assertThat(every10s.getIntervalMultiplier()).isEqualTo(1); + } +} diff --git a/operator-framework/src/main/java/io/javaoperatorsdk/operator/config/loader/ConfigLoader.java b/operator-framework/src/main/java/io/javaoperatorsdk/operator/config/loader/ConfigLoader.java index 8aed14da0d..df9e2e7a6c 100644 --- a/operator-framework/src/main/java/io/javaoperatorsdk/operator/config/loader/ConfigLoader.java +++ b/operator-framework/src/main/java/io/javaoperatorsdk/operator/config/loader/ConfigLoader.java @@ -286,12 +286,12 @@ private Consumer> bu } return overrider -> { - GenericRetry retry = GenericRetry.defaultLimitedExponentialRetry(); - maxAttempts.ifPresent(retry::setMaxAttempts); - initialInterval.ifPresent(retry::setInitialInterval); - intervalMultiplier.ifPresent(retry::setIntervalMultiplier); - maxInterval.ifPresent(retry::setMaxInterval); - overrider.withRetry(retry); + var retry = GenericRetry.builder(); + maxAttempts.ifPresent(retry::withMaxAttempts); + initialInterval.ifPresent(retry::withInitialInterval); + intervalMultiplier.ifPresent(retry::withIntervalMultiplier); + maxInterval.ifPresent(retry::withMaxInterval); + overrider.withRetry(retry.build()); }; } diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/errorstatushandler/ErrorStatusHandlerIT.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/errorstatushandler/ErrorStatusHandlerIT.java index 32e36c43a8..2fb9d9a3f9 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/errorstatushandler/ErrorStatusHandlerIT.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/errorstatushandler/ErrorStatusHandlerIT.java @@ -46,7 +46,8 @@ class ErrorStatusHandlerIT { LocallyRunOperatorExtension operator = LocallyRunOperatorExtension.builder() .withReconciler( - reconciler, new GenericRetry().setMaxAttempts(MAX_RETRY_ATTEMPTS).withLinearRetry()) + reconciler, + GenericRetry.builder().withMaxAttempts(MAX_RETRY_ATTEMPTS).withLinearRetry().build()) .build(); @Test diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/retry/RetryIT.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/retry/RetryIT.java index f3005e0991..53b540c246 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/retry/RetryIT.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/retry/RetryIT.java @@ -49,10 +49,11 @@ class RetryIT { LocallyRunOperatorExtension.builder() .withReconciler( new RetryTestCustomReconciler(NUMBER_FAILED_EXECUTIONS), - new GenericRetry() - .setInitialInterval(RETRY_INTERVAL) + GenericRetry.builder() + .withInitialInterval(RETRY_INTERVAL) .withLinearRetry() - .setMaxAttempts(MAX_RETRY_ATTEMPTS)) + .withMaxAttempts(MAX_RETRY_ATTEMPTS) + .build()) .build(); @Test diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/retry/RetryIntervalHonoredOnFrequentEventsIT.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/retry/RetryIntervalHonoredOnFrequentEventsIT.java index df525e8056..7582511323 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/retry/RetryIntervalHonoredOnFrequentEventsIT.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/retry/RetryIntervalHonoredOnFrequentEventsIT.java @@ -58,10 +58,11 @@ class RetryIntervalHonoredOnFrequentEventsIT { LocallyRunOperatorExtension.builder() .withReconciler( reconciler, - new GenericRetry() - .setInitialInterval(RETRY_INTERVAL_MILLIS) + GenericRetry.builder() + .withInitialInterval(RETRY_INTERVAL_MILLIS) .withLinearRetry() - .setMaxAttempts(MAX_RETRY_ATTEMPTS)) + .withMaxAttempts(MAX_RETRY_ATTEMPTS) + .build()) .build(); @Test diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/retry/RetryMaxAttemptIT.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/retry/RetryMaxAttemptIT.java index 5ca6df223f..9f2b41523e 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/retry/RetryMaxAttemptIT.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/retry/RetryMaxAttemptIT.java @@ -47,10 +47,11 @@ class RetryMaxAttemptIT { LocallyRunOperatorExtension.builder() .withReconciler( reconciler, - new GenericRetry() - .setInitialInterval(RETRY_INTERVAL) + GenericRetry.builder() + .withInitialInterval(RETRY_INTERVAL) .withLinearRetry() - .setMaxAttempts(MAX_RETRY_ATTEMPTS)) + .withMaxAttempts(MAX_RETRY_ATTEMPTS) + .build()) .build(); @Test diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/triggerallevent/eventing/TriggerReconcilerOnAllEventIT.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/triggerallevent/eventing/TriggerReconcilerOnAllEventIT.java index 3226611ea1..caeb46f769 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/triggerallevent/eventing/TriggerReconcilerOnAllEventIT.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/triggerallevent/eventing/TriggerReconcilerOnAllEventIT.java @@ -47,10 +47,11 @@ public class TriggerReconcilerOnAllEventIT { new TriggerReconcilerOnAllEventReconciler(), o -> o.withRetry( - new GenericRetry() - .setInitialInterval(800) - .setMaxAttempts(MAX_RETRY_ATTEMPTS) - .setIntervalMultiplier(1))) + GenericRetry.builder() + .withInitialInterval(800) + .withMaxAttempts(MAX_RETRY_ATTEMPTS) + .withIntervalMultiplier(1) + .build())) .build(); @Test