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


##########
api/maven-api-core/src/main/java/org/apache/maven/api/Constants.java:
##########
@@ -935,5 +935,18 @@ public final class Constants {
             readOnly = true)
     public static final String MAVEN_SITE_LIFECYCLE_DISABLED = 
"maven.site.lifecycle.disabled";
 
+    /**
+     * Whether to build the terminal on a background thread. When {@code 
false},
+     * the terminal is built synchronously during startup.
+     *
+     * @since 4.0.0

Review Comment:
   `@since 4.0.0` is incorrect — this constant is new in this PR, and `4.0.0` 
has already shipped without it. Use `@since 4.2.0` (matching 
`MAVEN_LIFECYCLE_FILTER` nearby).



##########
impl/maven-jline/src/main/java/org/apache/maven/jline/MessageUtils.java:
##########
@@ -161,7 +135,11 @@ public static void setColorEnabled(boolean enabled) {
     }
 
     public static boolean isColorEnabled() {
-        return colorEnabled && terminal != null;
+        if (terminal == null) {

Review Comment:
   Since `terminal` is not `volatile`, the null written by 
`doSystemUninstall()` may not be visible here — `isColorEnabled()` could 
observe a stale non-null `terminal` and return an incorrect result. The old 
single-read `return colorEnabled && terminal != null` was safer because it was 
a single volatile-width read; the new pattern needs `terminal` to be `volatile` 
to be correct.



##########
compat/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java:
##########
@@ -624,13 +619,6 @@ void logging(CliRequest cliRequest) throws ExitException {
             // Logging caches System.out; with -l the wait above already ran, 
so activate now.

Review Comment:
   Stale comment: `"with -l the wait above already ran"` — the 
`awaitTerminalInitialization()` call in the `-l` branch was removed by this PR 
(see the first hunk above). There is no "wait above" anymore; the comment 
should be updated or removed.



##########
impl/maven-jline/src/main/java/org/apache/maven/jline/MessageUtils.java:
##########
@@ -30,66 +31,67 @@
 import org.jline.terminal.Terminal;
 import org.jline.terminal.TerminalBuilder;
 import org.jline.terminal.impl.DeferredTerminal;
+import org.jline.utils.OSUtils;
 
 public class MessageUtils {
 
+    private static final int SIGINT_EXIT_CODE = 130;
+
     static Terminal terminal;
-    static LineReader reader;
+    static volatile LineReader reader;

Review Comment:
   `reader` is now `volatile` (correct for the lazy-init pattern in 
`getReader()`), but `terminal` (line 40) and `colorEnabled` (line 43) follow 
the same lazy-init / concurrent-null patterns without `volatile`. All three are 
written by `systemInstall`/`doSystemUninstall()` and read from multiple threads 
— should be treated consistently.



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