Skip to content

Commit 8846a57

Browse files
authored
Fixed InternalServiceError Error message on continue_as_new (#259)
1 parent 175886a commit 8846a57

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/main/java/com/uber/cadence/internal/testservice/TestWorkflowMutableState.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ void childWorkflowCompleted(String workflowId, ChildWorkflowExecutionCompletedEv
9696
void childWorkflowCanceled(String workflowId, ChildWorkflowExecutionCanceledEventAttributes a)
9797
throws InternalServiceError, EntityNotExistsError, BadRequestError;
9898

99-
void startWorkflow(Optional<SignalWorkflowExecutionRequest> signalWithStartSignal)
99+
void startWorkflow(
100+
boolean continuedAsNew, Optional<SignalWorkflowExecutionRequest> signalWithStartSignal)
100101
throws InternalServiceError, BadRequestError;
101102

102103
void startActivityTask(PollForActivityTaskResponse task, PollForActivityTaskRequest pollRequest)

src/main/java/com/uber/cadence/internal/testservice/TestWorkflowMutableStateImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,8 @@ private void processContinueAsNewWorkflowExecution(
959959
}
960960

961961
@Override
962-
public void startWorkflow(Optional<SignalWorkflowExecutionRequest> signalWithStartSignal)
962+
public void startWorkflow(
963+
boolean continuedAsNew, Optional<SignalWorkflowExecutionRequest> signalWithStartSignal)
963964
throws InternalServiceError, BadRequestError {
964965
try {
965966
update(
@@ -998,7 +999,7 @@ public void startWorkflow(Optional<SignalWorkflowExecutionRequest> signalWithSta
998999
} catch (EntityNotExistsError entityNotExistsError) {
9991000
throw new InternalServiceError(Throwables.getStackTraceAsString(entityNotExistsError));
10001001
}
1001-
if (parent.isPresent()) {
1002+
if (!continuedAsNew && parent.isPresent()) {
10021003
ChildWorkflowExecutionStartedEventAttributes a =
10031004
new ChildWorkflowExecutionStartedEventAttributes()
10041005
.setInitiatedEventId(parentChildInitiatedEventId.getAsLong())

src/main/java/com/uber/cadence/internal/testservice/TestWorkflowService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ StartWorkflowExecutionResponse startWorkflowExecutionImpl(
238238
Optional<RetryState> retryState = newRetryStateLocked(retryPolicy);
239239
return startWorkflowExecutionNoRunningCheckLocked(
240240
startRequest,
241+
false,
241242
retryState,
242243
backoffStartIntervalInSeconds,
243244
null,
@@ -275,6 +276,7 @@ private StartWorkflowExecutionResponse throwDuplicatedWorkflow(
275276

276277
private StartWorkflowExecutionResponse startWorkflowExecutionNoRunningCheckLocked(
277278
StartWorkflowExecutionRequest startRequest,
279+
boolean continuedAsNew,
278280
Optional<RetryState> retryState,
279281
int backoffStartIntervalInSeconds,
280282
byte[] lastCompletionResult,
@@ -298,7 +300,7 @@ private StartWorkflowExecutionResponse startWorkflowExecutionNoRunningCheckLocke
298300
ExecutionId executionId = new ExecutionId(domain, execution);
299301
executionsByWorkflowId.put(workflowId, mutableState);
300302
executions.put(executionId, mutableState);
301-
mutableState.startWorkflow(signalWithStartSignal);
303+
mutableState.startWorkflow(continuedAsNew, signalWithStartSignal);
302304
return new StartWorkflowExecutionResponse().setRunId(execution.getRunId());
303305
}
304306

@@ -592,6 +594,7 @@ public String continueAsNew(
592594
StartWorkflowExecutionResponse response =
593595
startWorkflowExecutionNoRunningCheckLocked(
594596
startRequest,
597+
true,
595598
retryState,
596599
a.getBackoffStartIntervalInSeconds(),
597600
a.getLastCompletionResult(),

0 commit comments

Comments
 (0)