From ee2d7c02352ab28f911b534d8cdb0315dc67d8e2 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 18 Feb 2026 11:50:55 +1000 Subject: [PATCH 1/2] Catch IOException with message "Resource deadlock avoided" which can happen on Unix level when multiple process try to lock same file Signed-off-by: Olivier Lamy --- .../internal/impl/DefaultTrackingFileManager.java | 11 +++++++++-- 1 file changed, 9 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 28b3b0fc96..88d5c44ecb 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 @@ -161,9 +161,16 @@ private FileLock fileLock(FileChannel channel, boolean shared) throws IOExceptio try { lock = channel.lock(0, Long.MAX_VALUE, shared); break; - } catch (OverlappingFileLockException e) { + } catch (OverlappingFileLockException | IOException e) { + // For Unix process sun.nio.ch.UnixFileDispatcherImpl.lock0() is a native method that can throw IOException + // with message "Resource deadlock avoided" + // the system call level is involving fcntl() or flock() + // If the kernel detects that granting the lock would result in a deadlock + // (where two processes are waiting for each other to release locks which can happen when two processes are trying to lock the same file), + // it returns an EDEADLK error, which Java throws as an IOException. + // Read another comment from https://github.com/bdeployteam/bdeploy/blob/7c04e7228d6d48b8990e6703a8d476e21024c639/bhive/src/main/java/io/bdeploy/bhive/objects/LockableDatabase.java#L57 if (attempts <= 0) { - throw new IOException(e); + throw (e instanceof IOException) ? (IOException) e : new IOException(e); } try { Thread.sleep(50L); From d52ec41163b4217e3f1d4a1457dc8cb8a33a3f90 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 18 Feb 2026 12:03:22 +1000 Subject: [PATCH 2/2] spotless Signed-off-by: Olivier Lamy --- .../aether/internal/impl/DefaultTrackingFileManager.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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 88d5c44ecb..760fcfc126 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 @@ -162,13 +162,16 @@ private FileLock fileLock(FileChannel channel, boolean shared) throws IOExceptio lock = channel.lock(0, Long.MAX_VALUE, shared); break; } catch (OverlappingFileLockException | IOException e) { - // For Unix process sun.nio.ch.UnixFileDispatcherImpl.lock0() is a native method that can throw IOException + // For Unix process sun.nio.ch.UnixFileDispatcherImpl.lock0() is a native method that can throw + // IOException // with message "Resource deadlock avoided" // the system call level is involving fcntl() or flock() // If the kernel detects that granting the lock would result in a deadlock - // (where two processes are waiting for each other to release locks which can happen when two processes are trying to lock the same file), + // (where two processes are waiting for each other to release locks which can happen when two processes + // are trying to lock the same file), // it returns an EDEADLK error, which Java throws as an IOException. - // Read another comment from https://github.com/bdeployteam/bdeploy/blob/7c04e7228d6d48b8990e6703a8d476e21024c639/bhive/src/main/java/io/bdeploy/bhive/objects/LockableDatabase.java#L57 + // Read another comment from + // https://github.com/bdeployteam/bdeploy/blob/7c04e7228d6d48b8990e6703a8d476e21024c639/bhive/src/main/java/io/bdeploy/bhive/objects/LockableDatabase.java#L57 if (attempts <= 0) { throw (e instanceof IOException) ? (IOException) e : new IOException(e); }