Skip to content

Commit afc3657

Browse files
committed
fix the result size in ParallelResult
1 parent 8712f6b commit afc3657

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

sdk-integration-tests/src/test/java/software/amazon/lambda/durable/ParallelIntegrationTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,10 +1055,8 @@ void testParallelWithFirstSuccessful_earlyTermination() {
10551055
var result = parallel.get();
10561056
assertEquals(ConcurrencyCompletionStatus.MIN_SUCCESSFUL_REACHED, result.completionStatus());
10571057
assertTrue(result.completionStatus().isSucceeded());
1058-
// todo: the result is constructed when handling parallel completion,
1059-
// which might be earlier than the last branch is added.
1060-
assertTrue(result.size() <= 3);
1061-
assertTrue(result.succeeded() <= result.size());
1058+
assertEquals(3, result.size());
1059+
assertTrue(result.succeeded() <= 3);
10621060
assertTrue(1 <= result.succeeded());
10631061

10641062
return "done";

sdk/src/main/java/software/amazon/lambda/durable/operation/ParallelOperation.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ protected void replay(Operation existing) {
107107
@Override
108108
public ParallelResult get() {
109109
join();
110-
return cachedResult;
110+
return new ParallelResult(
111+
getBranches().size(), // size might be updated after cached result is built
112+
cachedResult.succeeded(),
113+
cachedResult.failed(),
114+
cachedResult.completionStatus());
111115
}
112116

113117
/** Calls {@link #get()} if not already called. Guarantees that the context is closed. */

0 commit comments

Comments
 (0)