Skip to content

Commit 8201f72

Browse files
committed
[temporalio#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 temporalio#1727 Signed-off-by: Greg Haskins <[email protected]>
1 parent 089bbea commit 8201f72

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Diff for: temporal-sdk/src/main/java/io/temporal/internal/worker/LocalActivityWorker.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ private void submitAttempt(
127127
slotQueue.submitAttempt(reservationDat, isRetry, task);
128128
}
129129

130+
private RetryOptions getRetryOptions(PollActivityTaskQueueResponseOrBuilder activityTask) {
131+
if (isRetryPolicyNotSet(activityTask)) {
132+
return RetryOptions.getDefaultInstance();
133+
} else {
134+
return RetryOptionsUtils.toRetryOptions(activityTask.getRetryPolicy());
135+
}
136+
}
137+
130138
/**
131139
* @param executionContext execution context of the activity
132140
* @param activityTask activity task
@@ -154,11 +162,7 @@ private RetryDecision shouldRetry(
154162
throw (Error) attemptThrowable;
155163
}
156164

157-
if (isRetryPolicyNotSet(activityTask)) {
158-
return new RetryDecision(RetryState.RETRY_STATE_RETRY_POLICY_NOT_SET, null);
159-
}
160-
161-
RetryOptions retryOptions = RetryOptionsUtils.toRetryOptions(activityTask.getRetryPolicy());
165+
RetryOptions retryOptions = getRetryOptions(activityTask);
162166

163167
if (RetryOptionsUtils.isNotRetryable(retryOptions, attemptThrowable)) {
164168
return new RetryDecision(RetryState.RETRY_STATE_NON_RETRYABLE_FAILURE, null);
@@ -368,11 +372,7 @@ private RetryState shouldStillRetry(
368372
@Nullable Failure previousLocalExecutionFailure) {
369373
int currentAttempt = activityTask.getAttempt();
370374

371-
if (isRetryPolicyNotSet(activityTask)) {
372-
return RetryState.RETRY_STATE_RETRY_POLICY_NOT_SET;
373-
}
374-
375-
RetryOptions retryOptions = RetryOptionsUtils.toRetryOptions(activityTask.getRetryPolicy());
375+
RetryOptions retryOptions = getRetryOptions(activityTask);
376376

377377
if (previousLocalExecutionFailure != null
378378
&& previousLocalExecutionFailure.hasApplicationFailureInfo()

0 commit comments

Comments
 (0)