From 8201f720298acd5f88f44e8870ef73daef2f3be7 Mon Sep 17 00:00:00 2001 From: Greg Haskins Date: Mon, 7 Oct 2024 13:00:47 -0400 Subject: [PATCH] [#1727] Use default RetryOptions for LocalActivities when not set or setMaximumAttempts(0) Setting setMaximumAttempts=0 (or not setting any value, default = 0) for local activities should make the activity retry forever. This is currently broken because the logic treats both no policy set and a policy with all default values (including MaxiumAttempts = 0) as abort conditional. What should happen (at least according the doc and to align with normal activities) is that no policy set should be processed according to the default values of the retry policy, which includes unlimited retries when the MaxiumAttempts = 0. Fixes #1727 Signed-off-by: Greg Haskins --- .../internal/worker/LocalActivityWorker.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/temporal-sdk/src/main/java/io/temporal/internal/worker/LocalActivityWorker.java b/temporal-sdk/src/main/java/io/temporal/internal/worker/LocalActivityWorker.java index 69babb1fb..1c3fdbeea 100644 --- a/temporal-sdk/src/main/java/io/temporal/internal/worker/LocalActivityWorker.java +++ b/temporal-sdk/src/main/java/io/temporal/internal/worker/LocalActivityWorker.java @@ -127,6 +127,14 @@ private void submitAttempt( slotQueue.submitAttempt(reservationDat, isRetry, task); } + private RetryOptions getRetryOptions(PollActivityTaskQueueResponseOrBuilder activityTask) { + if (isRetryPolicyNotSet(activityTask)) { + return RetryOptions.getDefaultInstance(); + } else { + return RetryOptionsUtils.toRetryOptions(activityTask.getRetryPolicy()); + } + } + /** * @param executionContext execution context of the activity * @param activityTask activity task @@ -154,11 +162,7 @@ private RetryDecision shouldRetry( throw (Error) attemptThrowable; } - if (isRetryPolicyNotSet(activityTask)) { - return new RetryDecision(RetryState.RETRY_STATE_RETRY_POLICY_NOT_SET, null); - } - - RetryOptions retryOptions = RetryOptionsUtils.toRetryOptions(activityTask.getRetryPolicy()); + RetryOptions retryOptions = getRetryOptions(activityTask); if (RetryOptionsUtils.isNotRetryable(retryOptions, attemptThrowable)) { return new RetryDecision(RetryState.RETRY_STATE_NON_RETRYABLE_FAILURE, null); @@ -368,11 +372,7 @@ private RetryState shouldStillRetry( @Nullable Failure previousLocalExecutionFailure) { int currentAttempt = activityTask.getAttempt(); - if (isRetryPolicyNotSet(activityTask)) { - return RetryState.RETRY_STATE_RETRY_POLICY_NOT_SET; - } - - RetryOptions retryOptions = RetryOptionsUtils.toRetryOptions(activityTask.getRetryPolicy()); + RetryOptions retryOptions = getRetryOptions(activityTask); if (previousLocalExecutionFailure != null && previousLocalExecutionFailure.hasApplicationFailureInfo()