Skip to content

Commit c8742b1

Browse files
committed
fix commented code
1 parent 9fd4389 commit c8742b1

File tree

2 files changed

+18
-31
lines changed

2 files changed

+18
-31
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ subprojects {
1212
apply plugin: 'com.diffplug.spotless'
1313

1414
compileJava {
15-
// options.compilerArgs << "-Werror"
15+
options.compilerArgs << "-Werror"
1616
}
1717

1818
java {

core/src/main/java/io/temporal/samples/asyncchild/ParentWorkflowImpl.java

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,27 @@
2525
import io.temporal.workflow.ChildWorkflowOptions;
2626
import io.temporal.workflow.Promise;
2727
import io.temporal.workflow.Workflow;
28-
import java.util.ArrayList;
29-
import java.util.List;
3028

3129
public class ParentWorkflowImpl implements ParentWorkflow {
3230
@Override
3331
public WorkflowExecution executeParent() {
3432

35-
final List<Promise<WorkflowExecution>> promises = new ArrayList<>();
36-
37-
for (int i = 0; i < 1000; i++) {
38-
// We set the parentClosePolicy to "Abandon"
39-
// This will allow child workflow to continue execution after parent completes
40-
ChildWorkflowOptions childWorkflowOptions =
41-
ChildWorkflowOptions.newBuilder()
42-
.setWorkflowId("childWorkflow" + Math.random())
43-
.setParentClosePolicy(ParentClosePolicy.PARENT_CLOSE_POLICY_ABANDON)
44-
.build();
45-
46-
// Get the child workflow stub
47-
ChildWorkflow child =
48-
Workflow.newChildWorkflowStub(ChildWorkflow.class, childWorkflowOptions);
49-
// Start the child workflow async
50-
Async.function(child::executeChild);
51-
// Get the child workflow execution promise
52-
Promise<WorkflowExecution> childExecution = Workflow.getWorkflowExecution(child);
53-
// Call .get on the promise. This will block until the child workflow starts execution (or
54-
// start
55-
// fails)
56-
57-
promises.add(childExecution);
58-
}
59-
60-
Promise.allOf(promises).get();
61-
62-
return promises.get(0).get();
33+
// We set the parentClosePolicy to "Abandon"
34+
// This will allow child workflow to continue execution after parent completes
35+
ChildWorkflowOptions childWorkflowOptions =
36+
ChildWorkflowOptions.newBuilder()
37+
.setWorkflowId("childWorkflow")
38+
.setParentClosePolicy(ParentClosePolicy.PARENT_CLOSE_POLICY_ABANDON)
39+
.build();
40+
41+
// Get the child workflow stub
42+
ChildWorkflow child = Workflow.newChildWorkflowStub(ChildWorkflow.class, childWorkflowOptions);
43+
// Start the child workflow async
44+
Async.function(child::executeChild);
45+
// Get the child workflow execution promise
46+
Promise<WorkflowExecution> childExecution = Workflow.getWorkflowExecution(child);
47+
// Call .get on the promise. This will block until the child workflow starts execution (or start
48+
// fails)
49+
return childExecution.get();
6350
}
6451
}

0 commit comments

Comments
 (0)