@@ -4524,6 +4524,37 @@ public void testGetVersionRemovedInReplay2() {
45244524 assertEquals ("activity" , workflowStub .query ());
45254525 }
45264526
4527+ // The following test covers the scenario where getVersion call is removed before
4528+ // upsertSearchAttributes.
4529+ public static class TestGetVersionRemovedInReplay3WorkflowImpl implements TestWorkflow1 {
4530+ @ Override
4531+ public String execute (String taskList ) {
4532+ Map <String , Object > searchAttrMap = new HashMap <>();
4533+ searchAttrMap .put ("CustomKeywordField" , "abc" );
4534+ // Test removing a version check in replay code.
4535+ if (!getVersionExecuted .contains (taskList )) {
4536+ Workflow .getVersion ("test_change" , Workflow .DEFAULT_VERSION , 1 );
4537+ Workflow .upsertSearchAttributes (searchAttrMap );
4538+ getVersionExecuted .add (taskList );
4539+ } else {
4540+ Workflow .upsertSearchAttributes (searchAttrMap );
4541+ }
4542+
4543+ return "done" ;
4544+ }
4545+ }
4546+
4547+ @ Test
4548+ public void testGetVersionRemovedInReplay3 () {
4549+ startWorkerFor (TestGetVersionRemovedInReplay3WorkflowImpl .class );
4550+ TestWorkflow1 workflowStub =
4551+ workflowClient .newWorkflowStub (
4552+ TestWorkflow1 .class , newWorkflowOptionsBuilder (taskList ).build ());
4553+ String result = workflowStub .execute (taskList );
4554+ assertEquals ("done" , result );
4555+ tracer .setExpected ("getVersion" , "upsertSearchAttributes" );
4556+ }
4557+
45274558 public static class TestVersionNotSupportedWorkflowImpl implements TestWorkflow1 {
45284559
45294560 @ Override
0 commit comments