From 6be35251d14b1a12b259f24bb4e6abe2cbba4208 Mon Sep 17 00:00:00 2001 From: Stefan Oehme Date: Fri, 15 Aug 2025 19:45:49 +0200 Subject: [PATCH] [#11048] Fix race condition in MessageUtils Wait for the AnsiConsole#systemInstall call in the FastTerminal background thread before uninstalling. Otherwise a quickly finishing build might leave the terminal and system streams in a broken state. --- .../src/main/java/org/apache/maven/jline/MessageUtils.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/impl/maven-jline/src/main/java/org/apache/maven/jline/MessageUtils.java b/impl/maven-jline/src/main/java/org/apache/maven/jline/MessageUtils.java index 35a5416850b9..faf84c95a9a8 100644 --- a/impl/maven-jline/src/main/java/org/apache/maven/jline/MessageUtils.java +++ b/impl/maven-jline/src/main/java/org/apache/maven/jline/MessageUtils.java @@ -94,6 +94,10 @@ public static void systemUninstall() { private static void doSystemUninstall() { try { + if (terminal instanceof FastTerminal) { + // wait for the asynchronous systemInstall call before we uninstall to ensure a consistent state + ((FastTerminal) terminal).getTerminal(); + } AnsiConsole.systemUninstall(); } finally { terminal = null;