Skip to content

Commit ccbfb33

Browse files
authored
Merge pull request #39115 from shunping/cp-39096
[release-2.75] Cherry-pick #39096 to the branch
2 parents cf9f578 + d76047a commit ccbfb33

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -348,17 +348,23 @@ private void shutdownIfNecessary(State newState) {
348348
} catch (final Exception e) {
349349
errors.add(e);
350350
}
351-
pipelineState.compareAndSet(State.RUNNING, newState); // ensure we hit a terminal node
352-
if (!errors.isEmpty()) {
353-
final IllegalStateException 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);
351+
IllegalStateException exception = null;
352+
try {
353+
if (!errors.isEmpty()) {
354+
exception =
355+
new IllegalStateException(
356+
"Error"
357+
+ (errors.size() == 1 ? "" : "s")
358+
+ " occurred during executor shutdown:\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
366+
}
367+
if (exception != null) {
362368
throw exception;
363369
}
364370
}

0 commit comments

Comments
 (0)