Skip to content

Commit

Permalink
Fix null pointer on trigger immediately (#1865)
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns authored Sep 25, 2023
1 parent d50d274 commit 456da32
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public Builder setSpec(ScheduleSpec spec) {
}

/**
* Set the spec for this schedule
* Set the policy for this schedule
*
* @see ScheduleSpec
* @see SchedulePolicy
*/
public Builder setPolicy(SchedulePolicy policy) {
this.policy = policy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ public void createSchedule(CreateScheduleInput input) {
}

if (input.getOptions().isTriggerImmediately()) {
patchBuilder.setTriggerImmediately(
TriggerImmediatelyRequest.newBuilder()
.setOverlapPolicy(input.getSchedule().getPolicy().getOverlap())
.build());
TriggerImmediatelyRequest.Builder triggerRequest = TriggerImmediatelyRequest.newBuilder();
if (input.getSchedule().getPolicy() != null) {
triggerRequest.setOverlapPolicy(input.getSchedule().getPolicy().getOverlap());
}
patchBuilder.setTriggerImmediately(triggerRequest.build());
}

request.setInitialPatch(patchBuilder.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,20 @@ public void triggerSchedule() {
}
}

@Test
public void triggerScheduleNoPolicy() {
ScheduleClient client = createScheduleClient();
// Create schedule
ScheduleOptions options = ScheduleOptions.newBuilder().setTriggerImmediately(true).build();
String scheduleId = UUID.randomUUID().toString();
Schedule schedule =
createTestSchedule().setState(ScheduleState.newBuilder().setPaused(true).build()).build();
ScheduleHandle handle = client.createSchedule(scheduleId, schedule, options);
waitForActions(handle, 1);
// Cleanup schedule
handle.delete();
}

@Test
public void backfillSchedules() {
// assumeTrue("skipping for test server", SDKTestWorkflowRule.useExternalService);
Expand Down

0 comments on commit 456da32

Please sign in to comment.