arturobernalg opened a new pull request, #13650:
URL: https://github.com/apache/maven/pull/13650

   ## What and why
   
   Fixes #11167
   
   `MavenCli#initialize` resolved `multiModuleProjectDirectory` (the reactor 
root) with `File#getCanonicalFile()`, which asks the OS to resolve the path and 
can substitute it with a different one when a segment is a symlink, a junction, 
or, on Windows, a mapped network drive.
   
   [JDK-8355342](https://bugs.openjdk.org/browse/JDK-8355342) changed 
`getCanonicalFile()`'s behavior for mapped network drives starting with JDK 25. 
With a drive such as `H:\` mapped to a UNC share, `multiModuleProjectDirectory` 
silently became the UNC path of the share instead of the drive-relative path 
the user actually typed. Every module and parent path resolved relative to it 
afterwards inherited that wrong base, and the POM could no longer be found 
(`Non-readable POM H:\colo-01-fs02\...`, as reported in #11167).
   
   This is the exact same class of bug #11250 already fixed for `toRealPath()` 
elsewhere in this file: both `getCanonicalFile()` and `toRealPath()` ask the OS 
to resolve the path (following symlinks/junctions/mapped drives), rather than 
just normalizing it lexically. This one call site was missed.
   
   ## How
   
   This call now goes through the same `getCanonicalPath(Path)` helper this 
class already uses everywhere else since #11250, which only does 
`path.toAbsolutePath().normalize()` — no filesystem access, so nothing to 
resolve or substitute.
   
   ## Tests
   
   Added 
`MavenCliTest#testMultiModuleProjectDirectoryIsNotResolvedThroughASymlink`, 
which creates a real directory and a symlink to it, points 
`maven.multiModuleProjectDirectory` at the symlink, and asserts `initialize()` 
keeps the symlink path rather than resolving through it to the real one. This 
reproduces the same class of divergence as the Windows mapped-drive bug (JDK's 
`getCanonicalFile()` following filesystem-level redirection) in a way that's 
deterministic on any OS that supports symlinks; it's skipped where it doesn't 
(e.g. Windows without developer mode).
   
   Verified against current master:
   - The new test fails on unfixed code with the exact reported symptom 
(resolves through the symlink/mapped-location instead of keeping the given 
path), and passes with the fix.
   - `mvn -pl compat/maven-embedder test`: 46 tests, 0 failures.
   - `checkstyle:check` and `spotless:check` clean.
   
   https://claude.ai/code/session_01ReVkpYAznRPFBkHQFwYWcK
   
   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.
   
   - [x] I hereby declare this contribution to be licensed under the Apache 
License Version 2.0, January 2004
   - [x] I hereby declare that I have filed an Apache Individual Contributor 
License Agreement.


-- 
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]

Reply via email to