Resolve symbolic links before comparing the test JDK with Maven's JDK - #3475
Open
cwegener-79 wants to merge 1 commit into
Open
cwegener-79 wants to merge 1 commit into
cwegener-79 wants to merge 1 commit into
Conversation
ForkStarter#isForkJvmDifferentFromBuildJvm compared the JDK home of the tests with Maven's own JDK home by plain File#equals. Two different spellings of the same directory - a symbolic link or an automounted path, for instance - therefore counted as two different JDKs. That is common on CI machines: when the jvm parameter points at /opt/components/java/jdk8u492-b09/bin/java while the running JVM reports /srv/autofs/components/java/jdk8u492-b09/jre, both refer to the same JDK. Surefire then started an extra short-lived fork to list the test classes, which is pure overhead for every module of every build. Canonicalize both paths before comparing them, falling back to the absolute path when the file system cannot be queried.
cwegener-79
force-pushed
the
resolve-symlinked-jdk-home
branch
2 times, most recently
from
September 17, 2026 09:53
e4d719a to
a12bf01
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ForkStarter#isForkJvmDifferentFromBuildJvmcompares the JDK home of the tests with Maven's own JDK home using plainFile#equals:Two different spellings of the same directory therefore count as two different JDKs. This is easy to hit on CI machines, where the JDK is often reached through a symbolic link or an automounted path.
Since #3444, that comparison decides whether Surefire starts an extra short-lived fork to list the test classes. When both paths refer to the same JDK, that fork is pure overhead: one additional JVM startup per module, for every build.
What this PR does
Canonicalizes both paths before comparing them, falling back to the absolute path when the file system cannot be queried (unreadable directory, missing path).
Verification
ForkStarterTestcover relative segments, a symbolic link (skipped via assumption on platforms that do not allow creating one) and two genuinely different directories.forkCount=4and<jvm>pointing at a symlink to the running JDK:target/surefire/surefire-discovered-tests*.txtis written,No behaviour changes when the test JDK really is a different one - the listing fork is still used in that case.
Following this checklist to help us incorporate your
contribution quickly and easily:
mvn clean installto make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
mvn -Prun-its clean install). --> Was not possible in my infrastructureIf your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.