Skip to content

Commit 13c936b

Browse files
author
Liang Mei
committed
fix issues in Async promise execution
1 parent 9917088 commit 13c936b

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/main/java/com/uber/cadence/internal/sync/ChildWorkflowStubImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ public String getWorkflowType() {
5151

5252
@Override
5353
public Promise<WorkflowExecution> getExecution() {
54+
// Technically we can create and return a promise here in case the workflow is not started, and
55+
// create a separate started flag for signal method to check.
56+
// We don't expect this to be a critical issue for client users so we choose the simpler
57+
// approach of checking and throwing exception for now.
58+
if (execution == null) {
59+
throw new IllegalStateException("Workflow has not started.");
60+
}
5461
return execution;
5562
}
5663

src/main/java/com/uber/cadence/workflow/Async.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public static Promise<Void> procedure(Functions.Proc procedure) {
148148
* @return Promise that contains procedure result or failure
149149
*/
150150
public static <A1> Promise<Void> procedure(Functions.Proc1<A1> procedure, A1 arg1) {
151-
return procedure(() -> procedure.apply(arg1));
151+
return AsyncInternal.procedure(procedure, arg1);
152152
}
153153

154154
/**

src/main/java/com/uber/cadence/workflow/Functions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public interface Func6<T1, T2, T3, T4, T5, T6, R> extends Serializable {
5757
}
5858

5959
@FunctionalInterface
60-
public interface Proc {
60+
public interface Proc extends Serializable {
6161
void apply();
6262
}
6363

0 commit comments

Comments
 (0)