-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix pipe symbol parsing in .mvn/jvm.config (fix #11363) #11365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix pipe symbol parsing in .mvn/jvm.config (fix #11363) #11365
Conversation
465eef5 to
bdc5130
Compare
|
Updated all commit messages to use |
|
Fixed the integration test failures. The issue was that the previous implementation was escaping pipes in The updated fix:
This ensures that pipe symbols in JVM arguments (like All previously failing tests now pass:
|
c2acb11 to
c246af5
Compare
The concat_lines function in the Unix mvn script was using xargs -n 1 which split arguments by whitespace, causing pipe symbols (|) in JVM arguments to be interpreted as shell command separators. This fix replaces the problematic implementation with a line-by-line reader that preserves quoted arguments and special characters while maintaining all existing functionality: - Comments are still removed - Empty lines are still filtered out - Variable substitution (MAVEN_PROJECTBASEDIR) still works - Pipe symbols and other special characters are preserved The Windows mvn.cmd seems too limited, so we use a custom java class to parse the jvm.config file and process it. Added integration test to verify pipe symbols in jvm.config work correctly and don't cause shell parsing errors.
4d00db1 to
d1dc6f1
Compare
cstamas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit: why not use same Java helper on all platforms?
Answered in the description. |
4442e67 to
d1dc6f1
Compare
- Always initialize JVM_CONFIG_MAVEN_OPTS to empty to avoid inheriting stale values from environment - Add debug output to see actual values during IT runs - This prevents previous test runs from interfering with current test
Write JVM_CONFIG_MAVEN_OPTS and MAVEN_OPTS values to mvn-debug.txt in the project directory so we can check what values are being used during IT runs.
- Use random temp directory for each invocation to avoid conflicts - Capture stderr from Java parser to debug output file - Clean up temp directory after use - This ensures complete isolation between different Maven invocations
- Removed debug output to mvn-debug.txt - Cleaned up error capture logic - Ready for production use
This reverts commit 199b457.
Description
Fixes #11363
This PR fixes the issue where Maven 4 fails to parse pipe symbols (
|) and other special characters in.mvn/jvm.configfiles, causing shell/batch script parsing errors.Problem
When users tried to use JVM arguments with pipe symbols in
.mvn/jvm.config, such as:Maven 4 would fail with errors:
On Unix/Linux/macOS:
On Windows:
'*.de' is not recognized as an internal or external commandRoot Cause
The issue had different root causes on different platforms:
Unix/Linux/macOS
The
concat_linesfunction usedxargs -n 1which split arguments on whitespace, breaking quoted arguments. Additionally, pipe symbols were being interpreted as shell command separators duringeval execexecution.Windows
Windows batch script variable expansion with delayed expansion (
!var!) causes special characters like pipes to be interpreted as command separators. The complex batch script logic couldn't reliably handle pipes, quotes, and spaces simultaneously.Solution
We implemented different solutions for Unix and Windows due to their different capabilities and performance characteristics:
Windows: Java-based Parser (Required)
Created
JvmConfigParser.javathat:.mvn/jvm.configline by line#at start and end-of-line)${MAVEN_PROJECTBASEDIR}and$MAVEN_PROJECTBASEDIRsubstitutionThe Windows batch script (
mvn.cmd):set /p(no loops, no delayed expansion)Why Java for Windows? Windows batch scripts fundamentally cannot handle pipes in variables reliably. Any attempt to use delayed expansion (
!var!) causes special characters to be interpreted. The Java approach is the only robust solution.Unix: Improved awk-based Parser
Updated the
concat_linesfunction to:awkinstead ofxargsto preserve argument boundaries|→\|) forevalsafetyWhy different approaches? Unix shells have powerful text processing tools (awk, sed) that can handle this efficiently and with minimal overhead. Windows batch scripts lack these capabilities, making the Java approach necessary there. Performance testing showed the awk approach is ~200ms faster than Java compilation on Unix (320ms vs 520ms for
mvn -v).Changes
Core Changes
apache-maven/src/assembly/maven/bin/JvmConfigParser.java(NEW): Java parser for jvm.config filesapache-maven/src/assembly/maven/bin/mvn.cmd: Replaced complex batch script parsing with Java parser invocationapache-maven/src/assembly/maven/bin/mvn: Improvedconcat_linesfunction with awk-based pipe escapingapache-maven/src/assembly/component.xml: Include*.javafile in Windows distributionTesting
MavenITgh11363PipeSymbolsInJvmConfigTest: Integration test verifying pipe symbols work correctly.mvn/jvm.configcontaining pipe symbolsMavenITmng4559MultipleJvmArgsTest,MavenITmng4559SpacesInJvmOptsTest) continue to passTesting
The integration tests verify:
Compatibility
Example
Input (
.mvn/jvm.config):Output (arguments passed to JVM):
All special characters are preserved correctly! 🎉