Skip to content

Commit 0340876

Browse files
Respond to PR comments
1 parent 54f72b7 commit 0340876

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

temporal-sdk/src/main/java/io/temporal/client/WorkflowClient.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ static WorkflowClient newInstance(WorkflowServiceStubs service, WorkflowClientOp
159159
* @param runId Run id of the workflow execution.
160160
* @return Stub that implements workflowInterface and can be used to signal, update, or query it.
161161
* @deprecated Use {@link #newWorkflowStub(Class, WorkflowTargetOptions)} instead.
162+
* @apiNote This method is deprecated because the returned stub does not properly account for the
163+
* runId.
162164
*/
163165
@Deprecated
164166
<T> T newWorkflowStub(Class<T> workflowInterface, String workflowId, Optional<String> runId);
@@ -204,6 +206,8 @@ static WorkflowClient newInstance(WorkflowServiceStubs service, WorkflowClientOp
204206
* @param workflowType type of the workflow. Optional as it is used for error reporting only.
205207
* @return Stub that can be used to start workflow and later to signal or query it.
206208
* @deprecated Use {@link #newUntypedWorkflowStub(WorkflowTargetOptions, Optional)} instead.
209+
* @apiNote This method is deprecated because the returned stub does not properly account for the
210+
* runId.
207211
*/
208212
@Deprecated
209213
WorkflowStub newUntypedWorkflowStub(
@@ -217,6 +221,8 @@ WorkflowStub newUntypedWorkflowStub(
217221
* @param workflowType type of the workflow. Optional as it is used for error reporting only.
218222
* @return Stub that can be used to start workflow and later to signal or query it.
219223
* @deprecated Use {@link #newUntypedWorkflowStub(WorkflowTargetOptions, Optional)} instead.
224+
* @apiNote This method is deprecated because the returned stub does not properly account for the
225+
* runId.
220226
*/
221227
WorkflowStub newUntypedWorkflowStub(WorkflowExecution execution, Optional<String> workflowType);
222228

temporal-sdk/src/main/java/io/temporal/client/WorkflowStub.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* WorkflowStub is a client side stub to a single workflow instance. It can be used to start,
2020
* signal, query, update, wait for completion and cancel a workflow execution. Created through
2121
* {@link WorkflowClient#newUntypedWorkflowStub(String, WorkflowOptions)} or {@link
22-
* WorkflowClient#newUntypedWorkflowStub(WorkflowExecution, Optional)}.
22+
* WorkflowClient#newUntypedWorkflowStub(WorkflowTargetOptions, Optional)}.
2323
*/
2424
public interface WorkflowStub {
2525

temporal-sdk/src/main/java/io/temporal/client/WorkflowStubImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class WorkflowStubImpl implements WorkflowStub {
3535
// if null, this stub is created to bound to an existing execution.
3636
// This stub is created to bound to an existing execution otherwise.
3737
private final @Nullable WorkflowOptions options;
38+
// The SDK used to have a bug where signals, queries, updates targeted the current run
39+
// of the workflow even if the stub was created with a specific runId. This flag enables
40+
// that legacy behavior for backward compatibility.
3841
private final boolean legacyTargeting;
3942
private final @Nullable String firstExecutionRunId;
4043

@@ -603,8 +606,11 @@ private Throwable throwAsWorkflowFailureException(
603606
}
604607

605608
private void populateExecutionAfterStart(WorkflowExecution startedExecution) {
609+
// Currently we don't set the firstExecutionRunId on the stub after start because if the
610+
// start request didn't create a new execution (e.g. because of WorkflowIdReusePolicy),
611+
// the firstExecutionRunId should remain what it was before the start. To resolve this we
612+
// need https://github.com/temporalio/temporal/issues/8537 to be implemented.
606613
this.startedExecution.set(startedExecution);
607-
// this.firstExecutionRunId.set(startedExecution.getRunId());
608614
// bind to an execution without a runId, so queries follow runId chains by default
609615
this.execution.set(WorkflowExecution.newBuilder(startedExecution).setRunId("").build());
610616
}

0 commit comments

Comments
 (0)