gnodet-bot commented on code in PR #13955:
URL: https://github.com/apache/maven/pull/13955#discussion_r4552102575


##########
impl/maven-jline/src/main/java/org/apache/maven/jline/MessageUtils.java:
##########
@@ -47,29 +49,25 @@ public static void systemInstall() {
     }
 
     public static void systemInstall(Consumer<TerminalBuilder> 
builderConsumer, Consumer<Terminal> terminalConsumer) {
-        // Assign the FastTerminal to the field BEFORE starting the build 
thread so that code
-        // running on that thread (e.g. JLine's FFM provider init, logger 
calls) sees a non-null
-        // reference when it calls MessageUtils.getTerminal().  Thread.start() 
provides the
-        // happens-before edge that makes the assignment visible to the new 
thread.
-        FastTerminal ft = new FastTerminal(
-                () -> {
-                    TerminalBuilder builder =
-                            TerminalBuilder.builder().name("Maven").dumb(true);
-                    if (builderConsumer != null) {
-                        builderConsumer.accept(builder);
-                    }
-                    return builder.build();
-                },
-                terminal -> {
-                    MessageUtils.reader = createReader(terminal);
-                    AnsiConsole.setTerminal(terminal);
-                    AnsiConsole.systemInstall();
-                    if (terminalConsumer != null) {
-                        terminalConsumer.accept(terminal);
-                    }
-                });
-        MessageUtils.terminal = ft;
-        ft.start();
+        TerminalBuilder builder = 
TerminalBuilder.builder().name("Maven").dumb(true);
+        if (builderConsumer != null) {
+            builderConsumer.accept(builder);
+        }
+        // buildDeferred() returns a DeferredTerminal proxy immediately 
(~10ms).
+        // The real terminal is built on a background daemon thread; all proxy
+        // methods block transparently until it is ready.
+        DeferredTerminal deferred = (DeferredTerminal) builder.buildDeferred();

Review Comment:
   💡 **Nit:** `DeferredTerminal` is in the `impl` package (not the public API 
surface), and `TerminalBuilder.buildDeferred()` returns `Terminal`, so this 
cast is non-obvious to future readers. Consider documenting the contract:
   
   ```suggestion
           // buildDeferred() returns a DeferredTerminal proxy immediately 
(~10ms).
           // The real terminal is built on a background daemon thread; all 
proxy
           // methods block transparently until it is ready.
           // Cast is safe: buildDeferred() always returns DeferredTerminal — 
onComplete(),
           // isReady(), and getTerminal() are not on the Terminal interface.
           DeferredTerminal deferred = (DeferredTerminal) 
builder.buildDeferred();
   ```



-- 
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]

Reply via email to