gnodet opened a new pull request, #13587:
URL: https://github.com/apache/maven/pull/13587
## Problem
After `b28f385ca5` precompiled `JvmConfigParser`, the Windows CI started
seeing intermittent failures where `-Djvm.config=ok` from `.mvn/jvm.config` was
not passed to the Maven JVM:
```
AssertionFailedError: expected: <ok> but was: <${jvm.config}>
```
Affected tests: `MavenITmng6255FixConcatLines.testJvmConfigFileLF`,
`MavenITmng4559MultipleJvmArgsTest`, `MavenITmng4559SpacesInJvmOptsTest`,
`MavenITmng6223FindBasedir`.
## Root cause — `mvn.cmd` retry bug
`mvn.cmd` initialises `JVM_CONFIG_MAVEN_OPTS` to an empty string:
```bat
set JVM_CONFIG_MAVEN_OPTS=
```
Then it tries to retry the `set /p` read when nothing was captured:
```bat
if not defined JVM_CONFIG_MAVEN_OPTS (... retry ...)
```
In cmd.exe, `SET X=` (empty-string assignment) counts as **defined** — `if
not defined` never fires, so the retry is dead code. When Windows Defender or
another AV scanner briefly locks the temp file written by `JvmConfigParser`,
`set /p` reads nothing, the retry is skipped, and Maven starts with no
jvm.config options.
Before `b28f385ca5` the source-launch JVM took ~450 ms to start,
inadvertently giving the AV scanner time to release the file. The precompiled
class starts in ~30 ms — fast enough to hit the race reliably.
## Fixes
### 1. `mvn.cmd` — use string comparison instead of `if not defined`
```bat
- if not defined JVM_CONFIG_MAVEN_OPTS (
+ if "%JVM_CONFIG_MAVEN_OPTS%"=="" (
```
### 2. `MavenITmng6255FixConcatLines` — test isolation
All three line-ending variants (`lf`, `crlf`, `cr`) previously shared the
same `mng-6255/` directory, so each run overwrote the previous `jvm.config`.
Sequential runs mask failures because the CRLF variant (which happens to run
first alphabetically) succeeds, and the LF variant then overwrites the file —
but may find a stale result if any timing issue causes it to read before Maven
completes.
Each variant now gets its own copy of the project (`mng-6255-lf/`,
`mng-6255-crlf/`, `mng-6255-cr/`) to prevent cross-contamination and make
future parallelisation safe.
## Verification
Confirmed against the CI artifact from run `38939615920` (Windows-25):
- `expression-lf.properties`: `jvm-config=${jvm.config}` (broken — property
not passed)
- `expression-crlf.properties`: `jvm-config=ok` (working)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]