Skip to content

Commit

Permalink
Make sure UnsupportedContinueAsNewRequest doesn't fail the update
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns committed Aug 6, 2024
1 parent fc63989 commit 4ad6e96
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.temporal.failure.CanceledFailure;
import io.temporal.failure.TemporalFailure;
import io.temporal.internal.replay.ReplayWorkflowContext;
import io.temporal.internal.statemachines.UnsupportedContinueAsNewRequest;
import io.temporal.internal.worker.WorkflowExecutionException;
import io.temporal.worker.WorkflowImplementationOptions;
import io.temporal.workflow.Workflow;
Expand Down Expand Up @@ -123,6 +124,9 @@ public Optional<Payloads> handleExecuteUpdate(
io.temporal.api.common.v1.Header header) {
try {
return context.handleExecuteUpdate(updateName, input, eventId, new Header(header));
} catch (UnsupportedContinueAsNewRequest e) {
// Re-throw to fail the workflow task
throw e;
} catch (Throwable e) {
applyWorkflowFailurePolicyAndRethrow(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@

package io.temporal.workflow.updateTest;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;

import io.temporal.api.common.v1.WorkflowExecution;
import io.temporal.client.*;
import io.temporal.failure.ApplicationFailure;
import io.temporal.internal.statemachines.UnsupportedContinueAsNewRequest;
import io.temporal.testing.internal.SDKTestOptions;
import io.temporal.testing.internal.SDKTestWorkflowRule;
Expand Down Expand Up @@ -66,7 +68,11 @@ public void continueAsNewInUpdateHandler() {
.setUpdateName("update")
.setWaitForStage(WorkflowUpdateStage.ACCEPTED)
.build());
assertThrows(WorkflowFailedException.class, () -> stub.getResult(String.class));
WorkflowFailedException e =
assertThrows(WorkflowFailedException.class, () -> stub.getResult(String.class));
assertEquals(
"io.temporal.internal.statemachines.UnsupportedContinueAsNewRequest",
((ApplicationFailure) e.getCause()).getType());
}

public static class TestUpdateWorkflowImpl implements WorkflowWithUpdate {
Expand Down

0 comments on commit 4ad6e96

Please sign in to comment.