Skip to content

Commit bbaacea

Browse files
authored
Fix cron schedule merge issue in child workflow option (#269)
1 parent 6df4242 commit bbaacea

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/main/java/com/uber/cadence/workflow/ChildWorkflowOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static ChildWorkflowOptions merge(
5252
a.executionStartToCloseTimeoutSeconds(), o.getExecutionStartToCloseTimeout()))
5353
.setTaskList(OptionsUtils.merge(a.taskList(), o.getTaskList(), String.class))
5454
.setRetryOptions(RetryOptions.merge(r, o.getRetryOptions()))
55-
.setCronSchedule(cronAnnotation)
55+
.setCronSchedule(OptionsUtils.merge(cronAnnotation, o.getCronSchedule(), String.class))
5656
.validateAndBuildWithDefaults();
5757
}
5858

src/test/java/com/uber/cadence/client/WorkflowOptionsTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.uber.cadence.common.CronSchedule;
2222
import com.uber.cadence.common.MethodRetry;
2323
import com.uber.cadence.common.RetryOptions;
24+
import com.uber.cadence.workflow.ChildWorkflowOptions;
2425
import com.uber.cadence.workflow.WorkflowMethod;
2526
import java.lang.reflect.Method;
2627
import java.time.Duration;
@@ -116,6 +117,37 @@ public void testBothPresent() throws NoSuchMethodException {
116117
Assert.assertEquals("* 1 * * *", merged.getCronSchedule());
117118
}
118119

120+
@Test
121+
public void testChildWorkflowOptionMerge() throws NoSuchMethodException {
122+
RetryOptions retryOptions =
123+
new RetryOptions.Builder()
124+
.setDoNotRetry(IllegalArgumentException.class)
125+
.setMaximumAttempts(11111)
126+
.setBackoffCoefficient(1.55)
127+
.setMaximumInterval(Duration.ofDays(3))
128+
.setExpiration(Duration.ofDays(365))
129+
.setInitialInterval(Duration.ofMinutes(12))
130+
.build();
131+
132+
ChildWorkflowOptions o =
133+
new ChildWorkflowOptions.Builder()
134+
.setTaskList("foo")
135+
.setExecutionStartToCloseTimeout(Duration.ofSeconds(321))
136+
.setTaskStartToCloseTimeout(Duration.ofSeconds(13))
137+
.setWorkflowIdReusePolicy(WorkflowIdReusePolicy.RejectDuplicate)
138+
.setWorkflowId("bar")
139+
.setRetryOptions(retryOptions)
140+
.setCronSchedule("* 1 * * *")
141+
.build();
142+
Method method = WorkflowOptionsTest.class.getMethod("defaultWorkflowOptions");
143+
WorkflowMethod a = method.getAnnotation(WorkflowMethod.class);
144+
MethodRetry r = method.getAnnotation(MethodRetry.class);
145+
CronSchedule c = method.getAnnotation(CronSchedule.class);
146+
ChildWorkflowOptions merged = ChildWorkflowOptions.merge(a, r, c, o);
147+
Assert.assertEquals(retryOptions, merged.getRetryOptions());
148+
Assert.assertEquals("* 1 * * *", merged.getCronSchedule());
149+
}
150+
119151
@WorkflowMethod
120152
@CronSchedule("asdf * * * *")
121153
public void invalidCronScheduleAnnotation() {}

0 commit comments

Comments
 (0)