gnodet opened a new pull request, #344:
URL: https://github.com/apache/maven-clean-plugin/pull/344

   ## Summary
   
   Fix `mvn clean` crash with `NoSuchFileException` in Windows Docker 
environments when `followSymlinks=true`.
   
   ## Root Cause
   
   When `followSymlinks=true`, `Cleaner.delete(Path)` calls 
`getCanonicalPath(basedir, null)` which internally
   calls `path.toRealPath()`. On Windows Docker environments, volume-mount 
reparse points cause `toRealPath()`
   to throw `NoSuchFileException` due to 
[JDK-8172711](https://bugs.openjdk.org/browse/JDK-8172711).
   
   This only affects users who explicitly configure 
`<followSymLinks>true</followSymLinks>` — the default is
   `false`, so the vast majority of users are unaffected.
   
   See: 
https://github.com/apache/maven-clean-plugin/issues/262#issuecomment-5803635630
   
   ## Fix
   
   Wrap the `getCanonicalPath(basedir, null)` call in a `try/catch (IOException 
e)`. On failure, log a debug
   message and continue with the original (unresolved) `basedir`.
   
   `FOLLOW_LINKS` is still added to the `walkFileTree` options before the 
try/catch, so symlink following via
   `Files.walkFileTree` still works normally. The only loss on a `toRealPath()` 
failure is the loop-detection
   benefit of canonicalization — which is benign in practice (Docker volume 
mounts don't form symlink loops).
   
   Note: `BackgroundCleaner` already uses `toAbsolutePath()` instead of 
`toRealPath()` for a related reason
   (the staging directory may not exist yet) — this fix brings the same 
robustness to the foreground cleaner.
   
   ## Tests
   
   Added `deleteWithFollowSymlinksDeletesTarget` in `CleanerTest` to verify 
that `followSymlinks=true` correctly
   deletes through a symlink when `toRealPath()` succeeds (the normal case). 
The error path (when `toRealPath()`
   throws on Windows Docker reparse points) cannot be reproduced in standard CI 
and is documented in the test
   comment instead.
   
   All 16 tests pass (`./mvn verify -B`).
   
   ## Fixes
   
   Fixes #262
   


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