From 4eeab7d3806f6fdd86d72c4d9bfd2434be4ec919 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Mon, 17 Oct 2022 16:32:44 -0400 Subject: [PATCH] GH-319: Fix Javabean Setter Collision Resolves https://github.com/spring-projects/spring-retry/issues/319 Regression: https://github.com/spring-projects/spring-retry/commit/47c1e52900b32dc29fbf54699cfa4c60007b3c01 Multiple setters with different types. --- .../AnnotationAwareRetryOperationsInterceptor.java | 8 ++++---- .../retry/backoff/BackOffPolicyBuilder.java | 10 +++++----- .../retry/backoff/ExponentialBackOffPolicy.java | 6 +++--- .../retry/backoff/FixedBackOffPolicy.java | 4 ++-- .../retry/backoff/UniformRandomBackOffPolicy.java | 8 ++++---- .../retry/policy/CircuitBreakerRetryPolicy.java | 4 ++-- .../retry/policy/SimpleRetryPolicy.java | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/springframework/retry/annotation/AnnotationAwareRetryOperationsInterceptor.java b/src/main/java/org/springframework/retry/annotation/AnnotationAwareRetryOperationsInterceptor.java index dffa8b0..764f20b 100644 --- a/src/main/java/org/springframework/retry/annotation/AnnotationAwareRetryOperationsInterceptor.java +++ b/src/main/java/org/springframework/retry/annotation/AnnotationAwareRetryOperationsInterceptor.java @@ -275,7 +275,7 @@ public class AnnotationAwareRetryOperationsInterceptor implements IntroductionIn } } else { - breaker.setOpenTimeout(() -> evaluate(parsed, Long.class, false)); + breaker.openTimeoutSupplier(() -> evaluate(parsed, Long.class, false)); return; } } @@ -294,7 +294,7 @@ public class AnnotationAwareRetryOperationsInterceptor implements IntroductionIn } } else { - breaker.setResetTimeout(() -> evaluate(parsed, Long.class, false)); + breaker.resetTimeoutSupplier(() -> evaluate(parsed, Long.class, false)); } } breaker.setResetTimeout(circuit.resetTimeout()); @@ -366,7 +366,7 @@ public class AnnotationAwareRetryOperationsInterceptor implements IntroductionIn ? new ExpressionRetryPolicy(resolve(exceptionExpression)).withBeanFactory(this.beanFactory) : new SimpleRetryPolicy(); if (expression != null) { - simple.setMaxAttempts(() -> evaluate(expression, Integer.class, stateless)); + simple.maxAttemptsSupplier(() -> evaluate(expression, Integer.class, stateless)); } else { simple.setMaxAttempts(maxAttempts); @@ -388,7 +388,7 @@ public class AnnotationAwareRetryOperationsInterceptor implements IntroductionIn else { simple = new SimpleRetryPolicy(maxAttempts, policyMap, true, retryNotExcluded); if (expression != null) { - simple.setMaxAttempts(() -> evaluate(expression, Integer.class, stateless)); + simple.maxAttemptsSupplier(() -> evaluate(expression, Integer.class, stateless)); } } } diff --git a/src/main/java/org/springframework/retry/backoff/BackOffPolicyBuilder.java b/src/main/java/org/springframework/retry/backoff/BackOffPolicyBuilder.java index 9ffa1b0..da1dd8c 100644 --- a/src/main/java/org/springframework/retry/backoff/BackOffPolicyBuilder.java +++ b/src/main/java/org/springframework/retry/backoff/BackOffPolicyBuilder.java @@ -227,20 +227,20 @@ public class BackOffPolicyBuilder { policy.setInitialInterval(this.delay); } if (this.delaySupplier != null) { - policy.setInitialInterval(this.delaySupplier); + policy.initialIntervalSupplier(this.delaySupplier); } if (this.multiplier != null) { policy.setMultiplier(this.multiplier); } if (this.multiplierSupplier != null) { - policy.setMultiplier(this.multiplierSupplier); + policy.multiplierSupplier(this.multiplierSupplier); } if (this.maxDelay != null && this.delay != null) { policy.setMaxInterval( this.maxDelay > this.delay ? this.maxDelay : ExponentialBackOffPolicy.DEFAULT_MAX_INTERVAL); } if (this.maxDelaySupplier != null) { - policy.setMaxInterval(this.maxDelaySupplier); + policy.maxIntervalSupplier(this.maxDelaySupplier); } if (this.sleeper != null) { policy.setSleeper(this.sleeper); @@ -253,13 +253,13 @@ public class BackOffPolicyBuilder { policy.setMinBackOffPeriod(this.delay); } if (this.delaySupplier != null) { - policy.setMinBackOffPeriod(this.delaySupplier); + policy.minBackOffPeriodSupplier(this.delaySupplier); } if (this.maxDelay != null) { policy.setMaxBackOffPeriod(this.maxDelay); } if (this.maxDelaySupplier != null) { - policy.setMaxBackOffPeriod(this.maxDelaySupplier); + policy.maxBackOffPeriodSupplier(this.maxDelaySupplier); } if (this.sleeper != null) { policy.setSleeper(this.sleeper); diff --git a/src/main/java/org/springframework/retry/backoff/ExponentialBackOffPolicy.java b/src/main/java/org/springframework/retry/backoff/ExponentialBackOffPolicy.java index d20e37f..194f7d4 100644 --- a/src/main/java/org/springframework/retry/backoff/ExponentialBackOffPolicy.java +++ b/src/main/java/org/springframework/retry/backoff/ExponentialBackOffPolicy.java @@ -157,7 +157,7 @@ public class ExponentialBackOffPolicy implements SleepingBackOffPolicy initialIntervalSupplier) { + public void initialIntervalSupplier(Supplier initialIntervalSupplier) { Assert.notNull(initialIntervalSupplier, "'initialIntervalSupplier' cannot be null"); this.initialIntervalSupplier = initialIntervalSupplier; } @@ -168,7 +168,7 @@ public class ExponentialBackOffPolicy implements SleepingBackOffPolicy multiplierSupplier) { + public void multiplierSupplier(Supplier multiplierSupplier) { Assert.notNull(multiplierSupplier, "'multiplierSupplier' cannot be null"); this.multiplierSupplier = multiplierSupplier; } @@ -181,7 +181,7 @@ public class ExponentialBackOffPolicy implements SleepingBackOffPolicy maxIntervalSupplier) { + public void maxIntervalSupplier(Supplier maxIntervalSupplier) { Assert.notNull(maxIntervalSupplier, "'maxIntervalSupplier' cannot be null"); this.maxIntervalSupplier = maxIntervalSupplier; } diff --git a/src/main/java/org/springframework/retry/backoff/FixedBackOffPolicy.java b/src/main/java/org/springframework/retry/backoff/FixedBackOffPolicy.java index 5837eb0..db12bb9 100644 --- a/src/main/java/org/springframework/retry/backoff/FixedBackOffPolicy.java +++ b/src/main/java/org/springframework/retry/backoff/FixedBackOffPolicy.java @@ -48,7 +48,7 @@ public class FixedBackOffPolicy extends StatelessBackOffPolicy implements Sleepi public FixedBackOffPolicy withSleeper(Sleeper sleeper) { FixedBackOffPolicy res = new FixedBackOffPolicy(); - res.setBackOffPeriod(backOffPeriod); + res.backOffPeriodSupplier(backOffPeriod); res.setSleeper(sleeper); return res; } @@ -75,7 +75,7 @@ public class FixedBackOffPolicy extends StatelessBackOffPolicy implements Sleepi * @param backOffPeriodSupplier the back off period * @since 2.0 */ - public void setBackOffPeriod(Supplier backOffPeriodSupplier) { + public void backOffPeriodSupplier(Supplier backOffPeriodSupplier) { Assert.notNull(backOffPeriodSupplier, "'backOffPeriodSupplier' cannot be null"); this.backOffPeriod = backOffPeriodSupplier; } diff --git a/src/main/java/org/springframework/retry/backoff/UniformRandomBackOffPolicy.java b/src/main/java/org/springframework/retry/backoff/UniformRandomBackOffPolicy.java index 4534981..ef696d8 100644 --- a/src/main/java/org/springframework/retry/backoff/UniformRandomBackOffPolicy.java +++ b/src/main/java/org/springframework/retry/backoff/UniformRandomBackOffPolicy.java @@ -56,8 +56,8 @@ public class UniformRandomBackOffPolicy extends StatelessBackOffPolicy public UniformRandomBackOffPolicy withSleeper(Sleeper sleeper) { UniformRandomBackOffPolicy res = new UniformRandomBackOffPolicy(); - res.setMinBackOffPeriod(minBackOffPeriod); - res.setMaxBackOffPeriod(maxBackOffPeriod); + res.minBackOffPeriodSupplier(minBackOffPeriod); + res.maxBackOffPeriodSupplier(maxBackOffPeriod); res.setSleeper(sleeper); return res; } @@ -85,7 +85,7 @@ public class UniformRandomBackOffPolicy extends StatelessBackOffPolicy * @param backOffPeriodSupplier the backoff period * @since 2.0 */ - public void setMinBackOffPeriod(Supplier backOffPeriodSupplier) { + public void minBackOffPeriodSupplier(Supplier backOffPeriodSupplier) { Assert.notNull(backOffPeriodSupplier, "'backOffPeriodSupplier' cannot be null"); this.minBackOffPeriod = backOffPeriodSupplier; } @@ -113,7 +113,7 @@ public class UniformRandomBackOffPolicy extends StatelessBackOffPolicy * @param backOffPeriodSupplier the back off period * @since 2.0 */ - public void setMaxBackOffPeriod(Supplier backOffPeriodSupplier) { + public void maxBackOffPeriodSupplier(Supplier backOffPeriodSupplier) { Assert.notNull(backOffPeriodSupplier, "'backOffPeriodSupplier' cannot be null"); this.maxBackOffPeriod = backOffPeriodSupplier; } diff --git a/src/main/java/org/springframework/retry/policy/CircuitBreakerRetryPolicy.java b/src/main/java/org/springframework/retry/policy/CircuitBreakerRetryPolicy.java index faace4c..45aa756 100644 --- a/src/main/java/org/springframework/retry/policy/CircuitBreakerRetryPolicy.java +++ b/src/main/java/org/springframework/retry/policy/CircuitBreakerRetryPolicy.java @@ -73,7 +73,7 @@ public class CircuitBreakerRetryPolicy implements RetryPolicy { * @param timeoutSupplier a supplier for the timeout to set in milliseconds * @since 2.0 */ - public void setResetTimeout(Supplier timeoutSupplier) { + public void resetTimeoutSupplier(Supplier timeoutSupplier) { this.resetTimeoutSupplier = timeoutSupplier; } @@ -94,7 +94,7 @@ public class CircuitBreakerRetryPolicy implements RetryPolicy { * @param timeoutSupplier a supplier for the timeout to set in milliseconds * @since 2.0 */ - public void setOpenTimeout(Supplier timeoutSupplier) { + public void openTimeoutSupplier(Supplier timeoutSupplier) { this.openTimeoutSupplier = timeoutSupplier; } diff --git a/src/main/java/org/springframework/retry/policy/SimpleRetryPolicy.java b/src/main/java/org/springframework/retry/policy/SimpleRetryPolicy.java index fa57162..5470916 100644 --- a/src/main/java/org/springframework/retry/policy/SimpleRetryPolicy.java +++ b/src/main/java/org/springframework/retry/policy/SimpleRetryPolicy.java @@ -183,7 +183,7 @@ public class SimpleRetryPolicy implements RetryPolicy { * attempt. * @since 2.0 */ - public void setMaxAttempts(Supplier maxAttemptsSupplier) { + public void maxAttemptsSupplier(Supplier maxAttemptsSupplier) { Assert.notNull(maxAttemptsSupplier, "'maxAttemptsSupplier' cannot be null"); this.maxAttemptsSupplier = maxAttemptsSupplier; }