gnodet-bot commented on code in PR #13924:
URL: https://github.com/apache/maven/pull/13924#discussion_r4527323697
##########
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java:
##########
@@ -342,18 +357,44 @@ protected final void createTerminal(C context) {
}
doConfigureWithTerminal(context, terminal);
});
+ // Register cleanup immediately so it runs even if awaitTerminal()
is never reached
+ // (e.g. ExitException from helpOrVersionAndMayExit before
awaitTerminal is called).
+ context.closeables.add(MessageUtils::systemUninstall);
+ context.terminalBuildStarted = true;
+ }
+ }
+ /**
+ * Blocks until the terminal build started by {@link
#startTerminalBuild(C)} has completed,
+ * then registers the terminal and log appender on the context.
+ * No-op if the terminal was already set before {@link
#startTerminalBuild(C)} was called.
+ */
Review Comment:
🔍 **Javadoc inaccuracy** (introduced by this commit): After moving the drain
into `awaitTerminal`, the method is no longer a no-op when the terminal was
pre-set by an embedder — it also drains buffered log messages in that path. The
current Javadoc `"No-op if the terminal was already set before
startTerminalBuild() was called"` is misleading.
```suggestion
/**
* Blocks until the terminal build started by {@link
#startTerminalBuild(C)} has completed,
* then registers the terminal and log appender on the context, and
drains buffered
* log messages into the installed log sink.
* If the terminal was pre-set by an embedder before {@link
#startTerminalBuild(C)} was
* called, configures the context with that terminal and drains buffered
messages.
*/
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]