gnodet-bot commented on PR #13990:
URL: https://github.com/apache/maven/pull/13990#issuecomment-6868396178
Minor concern about exception handling in the `onComplete` callback
(`MessageUtils.java`):
```java
deferred.onComplete(terminal -> {
try {
MessageUtils.reader = createReader(terminal);
AnsiConsole.setTerminal(terminal);
AnsiConsole.systemInstall();
if (terminalConsumer != null) {
terminalConsumer.accept(terminal);
}
} finally {
ready.complete(null); // ← always completes "successfully"
}
});
```
If `createReader()` or `AnsiConsole.systemInstall()` throw, the exception
propagates out of the lambda but `ready.complete(null)` has already fired in
`finally`. `awaitTerminalInitialization()` then returns normally (via
`ready.join()`) despite the initialization failure — the caller has no way to
detect that `System.out` was never wrapped.
Consider:
```java
} catch (Exception e) {
ready.completeExceptionally(e);
return;
} finally {
if (!ready.isDone()) {
ready.complete(null);
}
}
```
Or simpler: catch the exception, call `ready.completeExceptionally(e)`, and
let `awaitTerminalInitialization()` propagate (or at least log) the failure
rather than silently continuing with a broken terminal state.
_This review was generated by an AI agent, Hermès on behalf of @gnodet._
<!-- reviewer: gnodet-bot -->
--
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]