Hello, the following code produces a different input parameter for the activity while replaying the workflow. I expected this code to produce a non-deterministic error. Why am I wrong?
public class ReplayTest {
@RegisterExtension
public static final TestWorkflowExtension testWorkflowExtension =
TestWorkflowExtension.newBuilder()
.setWorkflowTypes(
ReplayWorkflowImpl.class
)
.setActivityImplementations(new ReplayActivitiesImpl())
.build();
@Test
void replay_non_deterministic(WorkflowClient client, ReplayWorkflow wf) {
var execution = WorkflowStub.fromTyped(wf).start();
WorkflowStub.fromTyped(wf).getResult(String.class);
try {
var history = client.fetchHistory(execution.getWorkflowId());
WorkflowReplayer.replayWorkflowExecution(
history,
ReplayWorkflowImpl.class);
fail("Should throw exception");
} catch (Exception e) {
assertThat(e.getMessage()).contains("error=io.temporal.worker.NonDeterministicException");
}
}
@WorkflowInterface
public interface ReplayWorkflow {
@WorkflowMethod
String start();
}
@ActivityInterface
public interface ReplayActivities {
@ActivityMethod
String echo(String string);
}
public static class ReplayActivitiesImpl implements ReplayActivities{
@Override
public String echo(String string) {
return string;
}
}
public static class ReplayWorkflowImpl implements ReplayWorkflow {
ReplayActivities activities = Workflow.newActivityStub(
ReplayActivities.class,
ActivityOptions.newBuilder()
.setStartToCloseTimeout(Duration.ofSeconds(1))
.build());
@Override
public String start() {
var uuid = UUID.randomUUID().toString();
System.out.println("BEFORE " + uuid);
var result = activities.echo(uuid);
System.out.println("AFTER " + result);
return ts;
}
}
}