You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2026/05/20 21:13:24 UTC

(maven) branch master updated: Fix logging setup/teardown order (#11901)

This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/master by this push:
     new 5e5bf758f3 Fix logging setup/teardown order (#11901)
5e5bf758f3 is described below

commit 5e5bf758f326fd9706ba7a7eeea4a325c69db6fe
Author: Stefan Oehme <st...@gmail.com>
AuthorDate: Wed May 20 23:13:18 2026 +0200

    Fix logging setup/teardown order (#11901)
    
    Reorder ProjectBuildLogAppender registration in LookupInvoker so that
    it is added to the closeables list after the terminal setup. Since
    closeables are closed in reverse order (LIFO), this ensures the log
    sink is deregistered before the terminal is torn down, preventing
    StackOverflowErrors during shutdown.
    
    Closes #11901
---
 .../java/org/apache/maven/cling/invoker/LookupInvoker.java     | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
index 5ec158321d..d29e09a5fc 100644
--- a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
+++ b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
@@ -311,11 +311,6 @@ protected BuildEventListener doDetermineBuildEventListener(C context) {
 
     protected final void createTerminal(C context) {
         if (context.terminal == null) {
-            // Create the build log appender; also sets MavenSimpleLogger sink
-            ProjectBuildLogAppender projectBuildLogAppender =
-                    new ProjectBuildLogAppender(determineBuildEventListener(context));
-            context.closeables.add(projectBuildLogAppender);
-
             MessageUtils.systemInstall(
                     builder -> doCreateTerminal(context, builder),
                     terminal -> doConfigureWithTerminal(context, terminal));
@@ -323,6 +318,11 @@ protected final void createTerminal(C context) {
             context.terminal = MessageUtils.getTerminal();
             context.closeables.add(MessageUtils::systemUninstall);
             MessageUtils.registerShutdownHook(); // safety belt
+
+            // Create the build log appender; also sets MavenSimpleLogger sink
+            ProjectBuildLogAppender projectBuildLogAppender =
+                    new ProjectBuildLogAppender(determineBuildEventListener(context));
+            context.closeables.add(projectBuildLogAppender);
         } else {
             doConfigureWithTerminal(context, context.terminal);
         }