Skip to content

Commit 2e426d4

Browse files
fix: MaxRetryInterval was not propagate (#1685) (#1686)
(cherry picked from commit a2877aa) Signed-off-by: Javier Aliaga <javier@diagrid.io> Co-authored-by: Javier Aliaga <javier@diagrid.io>
1 parent ba40d22 commit 2e426d4

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

sdk-workflows/src/main/java/io/dapr/workflows/runtime/DefaultWorkflowContext.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ private RetryPolicy toRetryPolicy(WorkflowTaskRetryPolicy workflowTaskRetryPolic
281281
);
282282

283283
retryPolicy.setBackoffCoefficient(workflowTaskRetryPolicy.getBackoffCoefficient());
284+
if (workflowTaskRetryPolicy.getMaxRetryInterval() != null) {
285+
retryPolicy.setMaxRetryInterval(workflowTaskRetryPolicy.getMaxRetryInterval());
286+
}
284287
if (workflowTaskRetryPolicy.getRetryTimeout() != null) {
285288
retryPolicy.setRetryTimeout(workflowTaskRetryPolicy.getRetryTimeout());
286289
}

sdk-workflows/src/test/java/io/dapr/workflows/DefaultWorkflowContextTest.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,4 +523,44 @@ public void workflowRetryPolicyRetryThrowIllegalArgumentWhenRetryTimeoutIsLessTh
523523
.setRetryTimeout(Duration.ofSeconds(9))
524524
.build());
525525
}
526+
527+
@Test
528+
public void callActivityRetryPolicyMaxRetryIntervalShouldBePropagated() {
529+
String expectedName = "TestActivity";
530+
String expectedInput = "TestInput";
531+
Duration expectedMaxRetryInterval = Duration.ofSeconds(60);
532+
WorkflowTaskRetryPolicy retryPolicy = WorkflowTaskRetryPolicy.newBuilder()
533+
.setMaxNumberOfAttempts(5)
534+
.setFirstRetryInterval(Duration.ofSeconds(1))
535+
.setMaxRetryInterval(expectedMaxRetryInterval)
536+
.build();
537+
WorkflowTaskOptions options = new WorkflowTaskOptions(retryPolicy);
538+
ArgumentCaptor<TaskOptions> captor = ArgumentCaptor.forClass(TaskOptions.class);
539+
540+
context.callActivity(expectedName, expectedInput, options, String.class);
541+
542+
verify(mockInnerContext, times(1))
543+
.callActivity(eq(expectedName), eq(expectedInput), captor.capture(), eq(String.class));
544+
545+
assertEquals(expectedMaxRetryInterval, captor.getValue().getRetryPolicy().getMaxRetryInterval());
546+
}
547+
548+
@Test
549+
public void callActivityRetryPolicyDefaultMaxRetryIntervalShouldBeZeroWhenNotSet() {
550+
String expectedName = "TestActivity";
551+
String expectedInput = "TestInput";
552+
WorkflowTaskRetryPolicy retryPolicy = WorkflowTaskRetryPolicy.newBuilder()
553+
.setMaxNumberOfAttempts(5)
554+
.setFirstRetryInterval(Duration.ofSeconds(1))
555+
.build();
556+
WorkflowTaskOptions options = new WorkflowTaskOptions(retryPolicy);
557+
ArgumentCaptor<TaskOptions> captor = ArgumentCaptor.forClass(TaskOptions.class);
558+
559+
context.callActivity(expectedName, expectedInput, options, String.class);
560+
561+
verify(mockInnerContext, times(1))
562+
.callActivity(eq(expectedName), eq(expectedInput), captor.capture(), eq(String.class));
563+
564+
assertEquals(Duration.ZERO, captor.getValue().getRetryPolicy().getMaxRetryInterval());
565+
}
526566
}

0 commit comments

Comments
 (0)