This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch agent/tracking-file-delete in repository https://gitbox.apache.org/repos/asf/maven-resolver.git
commit e0fcf29a37566cf2055dc2bd5df956a480ccfa46 Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Sat Nov 7 22:55:59 2026 +0100 Release the file lock before deleting a tracking file Linux NFS clients refuse to unlink a file the same process still has open, so deleting the .lastUpdated file inside the try-with-resources that holds its channel and lock fails with EBUSY and, since 1.9.25, fails the build. Acquire the lock to wait for other processes, close it, then unlink. The unlocked window between the two is the one the code had before 1.9.25, when touchFile.delete() ran without any lock. Relates to #2269 --- .../eclipse/aether/internal/impl/LegacyTrackingFileManager.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/LegacyTrackingFileManager.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/LegacyTrackingFileManager.java index 160b5f72c..8335b7c7b 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/LegacyTrackingFileManager.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/LegacyTrackingFileManager.java @@ -140,8 +140,13 @@ public final class LegacyTrackingFileManager implements TrackingFileManager { public boolean delete(Path path) { if (Files.isReadable(path)) { synchronized (mutex(path)) { - try (FileChannel fileChannel = FileChannel.open(path, StandardOpenOption.WRITE); - FileLock unused = fileLock(fileChannel, false)) { + try { + // Take the lock to wait for other processes using the file, but release it and close the + // channel before unlinking: NFS refuses to unlink a file this process still has open (EBUSY). + try (FileChannel fileChannel = FileChannel.open(path, StandardOpenOption.WRITE); + FileLock unused = fileLock(fileChannel, false)) { + // acquiring the lock is the whole point + } Files.delete(path); return true; } catch (NoSuchFileException e) {
