Skip to content

[Backport maven-4.0.x] Fix #13405: Do not capture JVM stderr notices into jvm.config options - #13530

Merged
gnodet merged 1 commit into
apache:maven-4.0.xfrom
gnodet:backport/13447-to-4.0.x
Oct 15, 2026
Merged

gnodet merged 1 commit into
apache:maven-4.0.xfrom
gnodet:backport/13447-to-4.0.x

Conversation

@gnodet

@gnodet gnodet commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Backport of #13447 to maven-4.0.x.

Problem

In bin/mvn, concat_lines executes JvmConfigParser.java and captures output with 2>&1. When JAVA_TOOL_OPTIONS, JDK_JAVA_OPTIONS, or _JAVA_OPTIONS is set, the JVM prints notices such as Picked up JAVA_TOOL_OPTIONS: ... to stderr. Because stderr was merged into stdout, the notice was captured into MAVEN_OPTS, causing the JVM to treat Picked (or NOTE:) as the main class name on launch.

Solution

  • Separate stdout from stderr in bin/mvn when executing JvmConfigParser.java.
  • Redirect stderr to a temporary file and only display it if the parser exits with a non-zero code.
  • Added test-mvn-jvm-config.sh to verify that JVM notices do not pollute JVM arguments and that parser errors are still reported.
  • Added the test script to the shell-script-tests profile in apache-maven/pom.xml.

…tices into jvm.config options

- Separate stdout from stderr in bin/mvn when executing JvmConfigParser.java
- Redirect stderr to a temporary file; display it only on non-zero exit to avoid polluting MAVEN_OPTS with JVM tool notices (JAVA_TOOL_OPTIONS, JDK_JAVA_OPTIONS, _JAVA_OPTIONS)
- Add test-mvn-jvm-config.sh to verify JVM notices do not pollute JVM arguments and parser errors are still reported
- Register the test script in the shell-script-tests profile in apache-maven/pom.xml

Backport of apache#13447
@gnodet gnodet added bug Something isn't working java Pull requests that update Java code backport labels Oct 14, 2026
@gnodet gnodet added this to the 4.0.0 milestone Oct 14, 2026

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Clean backport of #13447 — the fix correctly separates JvmConfigParser stderr from stdout via a temp file, preventing JVM environment notices (JAVA_TOOL_OPTIONS, JDK_JAVA_OPTIONS, _JAVA_OPTIONS) from polluting MAVEN_OPTS. The test validates all three env vars and the error-reporting path; confirmed it catches the bug against the unpatched script and all 12 assertions pass against the patched version.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet
gnodet merged commit 2dacfff into apache:maven-4.0.x Oct 15, 2026
23 checks passed
@gnodet
gnodet deleted the backport/13447-to-4.0.x branch October 26, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport bug Something isn't working java Pull requests that update Java code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants