This is an automated email from the ASF dual-hosted git repository. elharo pushed a commit to branch fix/commandlineutils-inputfeeder-cleanup in repository https://gitbox.apache.org/repos/asf/maven-shared-utils.git
commit 9fe24089bf8d91ac6b1e048bd30c2162c5877390 Author: Elliotte Rusty Harold <[email protected]> AuthorDate: Wed Jul 1 09:37:42 2026 -0400 CommandLineUtils: ensure all pumpers are waited on in try-finally --- .../maven/shared/utils/cli/CommandLineUtils.java | 36 ++++++---------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java b/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java index 5c0307c..ee67690 100644 --- a/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java +++ b/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java @@ -274,34 +274,18 @@ public abstract class CommandLineUtils { int returnValue = p.waitFor(); - // TODO Find out if waitUntilDone needs to be called using a try-finally construct. The method may - // throw an - // InterruptedException so that calls to waitUntilDone may be skipped. - // try - // { - // if ( inputFeeder != null ) - // { - // inputFeeder.waitUntilDone(); - // } - // } - // finally - // { - // try - // { - // outputPumper.waitUntilDone(); - // } - // finally - // { - // errorPumper.waitUntilDone(); - // } - // } - if (inputFeeder != null) { - inputFeeder.waitUntilDone(); + try { + if (inputFeeder != null) { + inputFeeder.waitUntilDone(); + } + } finally { + try { + outputPumper.waitUntilDone(); + } finally { + errorPumper.waitUntilDone(); + } } - outputPumper.waitUntilDone(); - errorPumper.waitUntilDone(); - if (inputFeeder != null && inputFeeder.getException() != null) { throw new CommandLineException("Failure processing stdin.", inputFeeder.getException()); }
