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/08/28 13:32:18 UTC

(maven) branch backport/12864 created (now 7591aad052)

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

gnodet pushed a change to branch backport/12864
in repository https://gitbox.apache.org/repos/asf/maven.git


      at 7591aad052 Fix #12749: suppress false ERROR in mvnsh for successful commands (#12864)

This branch includes the following new commits:

     new 7591aad052 Fix #12749: suppress false ERROR in mvnsh for successful commands (#12864)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(maven) 01/01: Fix #12749: suppress false ERROR in mvnsh for successful commands (#12864)

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 7591aad0525dfa21a51798ca66a723c910676411
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Aug 28 15:26:06 2026 +0200

    Fix #12749: suppress false ERROR in mvnsh for successful commands (#12864)
    
    The mvn, mvnenc, and mvnup commands in mvnsh unconditionally logged
    an ERROR when catching ExitException, even when the exit code was 0
    (success). This made successful commands like `mvn --version` display
    a confusing red "[ERROR] mvn command exited with exit code 0".
    
    Only log the error message when the exit code is non-zero, consistent
    with how the shell (!) command already handles exit codes.
    
    Co-authored-by: Claude Opus 4.6 <no...@anthropic.com>
---
 .../mvnsh/builtin/BuiltinShellCommandRegistryFactory.java    | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnsh/builtin/BuiltinShellCommandRegistryFactory.java b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnsh/builtin/BuiltinShellCommandRegistryFactory.java
index a221e1b5b1..3d989b60ed 100644
--- a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnsh/builtin/BuiltinShellCommandRegistryFactory.java
+++ b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnsh/builtin/BuiltinShellCommandRegistryFactory.java
@@ -202,7 +202,9 @@ private void mvn(CommandInput input) {
                                 .cwd(shellContext.cwd.get())
                                 .build()));
             } catch (InvokerException.ExitException e) {
-                shellContext.logger.error("mvn command exited with exit code " + e.getExitCode());
+                if (e.getExitCode() != 0) {
+                    shellContext.logger.error("mvn command exited with exit code " + e.getExitCode());
+                }
             } catch (Exception e) {
                 saveException(e);
             }
@@ -240,7 +242,9 @@ private void mvnenc(CommandInput input) {
                                 .cwd(shellContext.cwd.get())
                                 .build()));
             } catch (InvokerException.ExitException e) {
-                shellContext.logger.error("mvnenc command exited with exit code " + e.getExitCode());
+                if (e.getExitCode() != 0) {
+                    shellContext.logger.error("mvnenc command exited with exit code " + e.getExitCode());
+                }
             } catch (Exception e) {
                 saveException(e);
             }
@@ -258,7 +262,9 @@ private void mvnup(CommandInput input) {
                                 .cwd(shellContext.cwd.get())
                                 .build()));
             } catch (InvokerException.ExitException e) {
-                shellContext.logger.error("mvnup command exited with exit code " + e.getExitCode());
+                if (e.getExitCode() != 0) {
+                    shellContext.logger.error("mvnup command exited with exit code " + e.getExitCode());
+                }
             } catch (Exception e) {
                 saveException(e);
             }