kamchy opened a new issue, #2269:
URL: https://github.com/apache/maven-resolver/issues/2269

   ### Affected version
   
   1.9.25
   
   ### Bug description
   
   Since Resolver 1.9.25 (Maven 3.9.12+), `DefaultTrackingFileManager.delete()` 
(now `LegacyTrackingFileManager` on master) opens the tracking file with 
`FileChannel.open(path, WRITE)`, acquires an exclusive FileLock, and calls 
`Files.delete(path)` while the channel and lock are still open. It also thtrows 
IOException as UncheckedIOException.
   
   If a local repository is on an NFS mount (Linux client), then deleting / 
unlinking a file that the same process has opened (and locked!) fails:
   ```
     [WARNING] Failed to delete tracking file 
'/var/tmp/ump/.m2/org/apache/maven/plugins/maven-clean-plugin/3.2.0/maven-clean-plugin-3.2.0.pom.lastUpdated'
     java.nio.file.FileSystemException: 
.../maven-clean-plugin-3.2.0.pom.lastUpdated: Device or resource busy
         at org.eclipse.aether.internal.impl.DefaultTrackingFileManager.delete 
(DefaultTrackingFileManager.java:130)
         at 
org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.touchArtifact 
(DefaultUpdateCheckManager.java:479)
         at 
org.eclipse.aether.internal.impl.DefaultArtifactResolver.evaluateDownloads 
(DefaultArtifactResolver.java:649)
     [ERROR] java.io.UncheckedIOException: java.nio.file.FileSystemException: 
... Device or resource busy
   ```
   
   The build fails right after the first successful download. Before 1.9.25, 
`touchArtifact()` called `touchFile.delete()` and ignored the result, so the 
same environment worked (and stale .lastUpdated file was left there).
   
   Steps to reproduce: 
   - local repository on an NFS mount (-Dmaven.repo.local=/nfs/.m2)
   - run any build with Maven 3.9.12+  that downloads at least one artifact
   
   Expected behaviour: tracking file is deleted or a warning is logged
   
   Suggested fix: close the channel/lock before `Files.delete` (or use 
`Files.deleteIfExists` after the try block), or perhaps treat 
`FileSystemException` on delete as non-fatal. 
   
   Workaround we use: -Dmaven.repo.local=<local disk> 
-Dmaven.repo.local.tail=<NFS repo> (tracking files are
   never written to NFS)


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