Repository navigation
Fix #13405: Do not capture JVM stderr notices into jvm.config options - #13447
Conversation
gnodet-bot
left a comment
There was a problem hiding this comment.
Two advisory notes on the stderr-separation approach.
The fix correctly isolates JVM stderr notices (e.g. JAVA_TOOL_OPTIONS) from the parsed JVM options — that's the right approach and the new test script is a solid addition.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
# Conflicts: # apache-maven/src/assembly/maven/bin/mvn
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — both advisory findings have been addressed, but the new test script has a critical stub bug that prevents it from verifying the fix.
Prior findings status:
- 💡 Missing signal trap — ✅ addressed:
trap 'rm -f "$parser_stderr_file"' EXIT INT TERMadded immediately aftermktemp - 💡
elifsilently drops stdout in error path — ✅ addressed: replaced with two separateifblocks so both stderr and stdout are always printed on parser failure
New finding: The java stub's JvmConfigParser emulation never fires — see inline comment.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
… source-launch (.java) The java stub matched $1 against '*JvmConfigParser.java)' (source-launch convention), but the mvn script invokes the precompiled class: "$JAVACMD" -cp "$MAVEN_HOME/bin" JvmConfigParser <config> <basedir> With the precompiled invocation, $1=-cp, $2=<bin-dir>, $3=JvmConfigParser, $4=<jvm.config path>. The old pattern never matched, so the stub fell through to the generic arg-printer and the jvm.config options were never parsed into MAVEN_OPTS — all assertions silently passed without verifying the primary fix. Fix: match on $3 and read the config file from $4.
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — all 3 findings have been addressed.
- 💡 Missing signal trap — ✅ addressed:
trap 'rm -f "$parser_stderr_file"' EXIT INT TERMadded immediately aftermktemp - 💡
elifsilently drops stdout in error path — ✅ addressed: replaced with two separateifblocks ⚠️ Broken stub:JvmConfigParseremulation never fires — ✅ addressed:case "$3" in JvmConfigParser)now correctly matches the precompiled invocation and reads the config from$4
The test stub fix in the last commit is correct. The eval-based launch in bin/mvn means quoted-token output from the JvmConfigParser stub is properly handled by eval exec "$cmd", and the bracketed args in the main launch stub will match the [-Xmx512m] assertions. The <skip>${skipTests}</skip> pattern in pom.xml is consistent with the existing shell script test executions.
LGTM.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
Thank you for the review and approval, @gnodet! |
…into jvm.config options (#13530) - 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 #13447 Co-authored-by: Yashi Singhal <[email protected]>
Fixes #13405
Problem
In
bin/mvn,concat_linesexecutesJvmConfigParser.javaand captures output with2>&1. WhenJAVA_TOOL_OPTIONS,JDK_JAVA_OPTIONS, or_JAVA_OPTIONSis set, the JVM prints notices such asPicked up JAVA_TOOL_OPTIONS: ...tostderr. Becausestderrwas merged intostdout, the notice was captured intoMAVEN_OPTS, causing the JVM to treatPicked(orNOTE:) as the main class name on launch.Solution
JvmConfigParser.javainbin/mvn.test-mvn-jvm-config.shto verify that JVM notices do not pollute JVM arguments and that parser errors are still reported.shell-script-testsprofile inapache-maven/pom.xml.Note: Please consider backporting to
maven-4.0.xas well, as this affects 4.0.0-rc-7.Verification
Verified with Git Bash / POSIX test runners:
sh apache-maven/src/test/scripts/test-mvn-jvm-config.sh(all assertions pass)sh apache-maven/src/test/scripts/test-mvn-path-conversion.sh(all assertions pass)To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
check one of the following: