Skip to content

Commit ec83eb2

Browse files
committed
Apply suggested fix
1 parent 0d4efb1 commit ec83eb2

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

runners/direct-java/src/main/java/org/apache/beam/runners/direct/ExecutorServiceParallelExecutor.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -349,18 +349,21 @@ private void shutdownIfNecessary(State newState) {
349349
errors.add(e);
350350
}
351351
IllegalStateException exception = null;
352-
if (!errors.isEmpty()) {
353-
exception =
354-
new IllegalStateException(
355-
"Error"
356-
+ (errors.size() == 1 ? "" : "s")
357-
+ " during executor shutdown:\n"
358-
+ errors.stream()
359-
.map(Exception::getMessage)
360-
.collect(Collectors.joining("\n- ", "- ", "")));
361-
visibleUpdates.failed(exception);
352+
try {
353+
if (!errors.isEmpty()) {
354+
exception =
355+
new IllegalStateException(
356+
"Error"
357+
+ (errors.size() == 1 ? "" : "s")
358+
+ " occurred during pipeline execution:\\n"
359+
+ errors.stream()
360+
.map(e -> e.getMessage() == null ? e.getClass().getName() : e.getMessage())
361+
.collect(Collectors.joining("\\n- ", "- ", "")));
362+
visibleUpdates.failed(exception);
363+
}
364+
} finally {
365+
pipelineState.compareAndSet(State.RUNNING, newState); // ensure we hit a terminal node
362366
}
363-
pipelineState.compareAndSet(State.RUNNING, newState); // ensure we hit a terminal node
364367
if (exception != null) {
365368
throw exception;
366369
}

0 commit comments

Comments
 (0)