22// SPDX-License-Identifier: Apache-2.0
33package software .amazon .lambda .durable .config ;
44
5+ import software .amazon .lambda .durable .retry .RetryStrategies ;
56import software .amazon .lambda .durable .retry .RetryStrategy ;
67
78/**
89 * Configuration for {@link software.amazon.lambda.durable.util.WithRetryHelper#withRetry}.
910 *
1011 * <p>Uses the same {@link RetryStrategy} shape that developers already know from {@link StepConfig}, so there are zero
11- * new retry concepts to learn.
12+ * new retry concepts to learn. If no retry strategy is specified, {@link RetryStrategies.Presets#DEFAULT} is used.
1213 */
1314public class WithRetryConfig {
1415 private final RetryStrategy retryStrategy ;
@@ -20,12 +21,13 @@ private WithRetryConfig(Builder builder) {
2021 }
2122
2223 /**
23- * Returns the retry strategy. Same type as {@link StepConfig#retryStrategy()}.
24+ * Returns the retry strategy, or the default strategy if not specified. Same type as
25+ * {@link StepConfig#retryStrategy()}.
2426 *
2527 * @return the retry strategy, never null
2628 */
2729 public RetryStrategy retryStrategy () {
28- return retryStrategy ;
30+ return retryStrategy != null ? retryStrategy : RetryStrategies . Presets . DEFAULT ;
2931 }
3032
3133 /**
@@ -56,7 +58,7 @@ public static class Builder {
5658 private Builder () {}
5759
5860 /**
59- * Sets the retry strategy. Required .
61+ * Sets the retry strategy. Optional — defaults to {@link RetryStrategies.Presets#DEFAULT} if not set .
6062 *
6163 * <p>Reuses the exact same {@link RetryStrategy} interface from {@link StepConfig}. All existing factory
6264 * methods ({@link software.amazon.lambda.durable.retry.RetryStrategies#exponentialBackoff},
@@ -91,12 +93,8 @@ public Builder wrapInChildContext(boolean wrapInChildContext) {
9193 * Builds the {@link WithRetryConfig} instance.
9294 *
9395 * @return a new config with the configured options
94- * @throws IllegalArgumentException if retryStrategy is not set
9596 */
9697 public WithRetryConfig build () {
97- if (retryStrategy == null ) {
98- throw new IllegalArgumentException ("retryStrategy is required" );
99- }
10098 return new WithRetryConfig (this );
10199 }
102100 }
0 commit comments