From 8a83069e14e2d6c510edb1e86be591ee8d230bc2 Mon Sep 17 00:00:00 2001 From: Vladimir Kulev Date: Tue, 25 Jul 2023 15:37:15 +0300 Subject: [PATCH] Fix MethodRetry annotation handling for unlimited maximum attempts --- src/main/java/com/uber/cadence/common/RetryOptions.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/uber/cadence/common/RetryOptions.java b/src/main/java/com/uber/cadence/common/RetryOptions.java index e47cad163..70e4501bd 100644 --- a/src/main/java/com/uber/cadence/common/RetryOptions.java +++ b/src/main/java/com/uber/cadence/common/RetryOptions.java @@ -64,8 +64,11 @@ public static RetryOptions merge(MethodRetry r, RetryOptions o) { } else { builder.setBackoffCoefficient(DEFAULT_BACKOFF_COEFFICIENT); } + int maximumAttempts = merge(r.maximumAttempts(), o.getMaximumAttempts(), int.class); + if (maximumAttempts != 0) { + builder.setMaximumAttempts(maximumAttempts); + } return builder - .setMaximumAttempts(merge(r.maximumAttempts(), o.getMaximumAttempts(), int.class)) .setDoNotRetry(merge(r.doNotRetry(), o.getDoNotRetry())) .validateBuildWithDefaults(); }