This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch maven-resolver-1.9.x
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git
The following commit(s) were added to refs/heads/maven-resolver-1.9.x by this
push:
new 1e6b86b12 Release the file lock before deleting a tracking file
1e6b86b12 is described below
commit 1e6b86b1236a66bbc4288dbe908ed71bbf396a4d
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Sat Nov 7 22:55:57 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.
Fixes #2269
---
.../eclipse/aether/internal/impl/DefaultTrackingFileManager.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git
a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTrackingFileManager.java
b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTrackingFileManager.java
index 83785ef47..0e86c4a87 100644
---
a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTrackingFileManager.java
+++
b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTrackingFileManager.java
@@ -125,8 +125,13 @@ public final class DefaultTrackingFileManager implements
TrackingFileManager {
Path path = file.toPath();
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) {