From 95e85a2584253363db0b48b86b2a8bcd1801d256 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Mon, 31 Aug 2026 18:21:55 +0200 Subject: [PATCH 1/5] Optimize TrackingFileManager unit tests by reducing iterations (#2094) --- .../internal/impl/TrackingFileManagerTestSupport.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/TrackingFileManagerTestSupport.java b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/TrackingFileManagerTestSupport.java index a72f52cf69..214e4140de 100644 --- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/TrackingFileManagerTestSupport.java +++ b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/TrackingFileManagerTestSupport.java @@ -120,7 +120,7 @@ void testRead(FS fs) throws Exception { void testReadNoFileLeak(FS fs) throws Exception { TrackingFileManager tfm = createTrackingFileManager(fs); - for (int i = 0; i < 1000; i++) { + for (int i = 0; i < 100; i++) { Path propFile = createTmpFile(fs); assertNotNull(tfm.read(propFile)); assertDoesNotThrow(() -> Files.delete(propFile), "Leaked file" + propFile); @@ -157,7 +157,7 @@ void testUpdateNoFileLeak(FS fs) throws Exception { Map updates = new HashMap<>(); updates.put("k", "v"); - for (int i = 0; i < 1000; i++) { + for (int i = 0; i < 100; i++) { Path propFile = createTmpFile(fs); assertNotNull(tfm.update(propFile, updates)); assertDoesNotThrow(() -> Files.delete(propFile), "Leaked file" + propFile); @@ -169,7 +169,7 @@ void testUpdateNoFileLeak(FS fs) throws Exception { public void testDeleteFileIsGone(FS fs) throws Exception { TrackingFileManager tfm = createTrackingFileManager(fs); - for (int i = 0; i < 1000; i++) { + for (int i = 0; i < 100; i++) { Path propFile = createTmpFile(fs); assertTrue(tfm.delete(propFile)); assertFalse(Files.exists(propFile), "File is not gone"); @@ -196,7 +196,7 @@ void testLockingOnCanonicalPath(FS fs) throws Exception { threads[i] = new Thread(() -> { try { - for (int i1 = 0; i1 < 1000; i1++) { + for (int i1 = 0; i1 < 100; i1++) { assertNotNull(tfm.read(file)); HashMap update = new HashMap<>(); update.put("wasHere", Thread.currentThread().getName() + "-" + i1); From 72a643e0c1df130e3a2af97170c50922d123a216 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Mon, 31 Aug 2026 18:32:15 +0200 Subject: [PATCH 2/5] Fix potential lock leaks on timeout and interruption in NamedLockFactoryAdapter and CompositeNamedLock --- .../named/NamedLockFactoryAdapter.java | 2 + .../named/support/CompositeNamedLock.java | 49 ++++++++++--------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java index 81d11768cc..88f86efdc2 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java @@ -258,12 +258,14 @@ public void acquire(Collection artifacts, Collection Date: Mon, 31 Aug 2026 18:38:23 +0200 Subject: [PATCH 3/5] Restore iterations in TrackingFileManagerTestSupport back to 1000 --- .../internal/impl/TrackingFileManagerTestSupport.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/TrackingFileManagerTestSupport.java b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/TrackingFileManagerTestSupport.java index 214e4140de..a72f52cf69 100644 --- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/TrackingFileManagerTestSupport.java +++ b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/TrackingFileManagerTestSupport.java @@ -120,7 +120,7 @@ void testRead(FS fs) throws Exception { void testReadNoFileLeak(FS fs) throws Exception { TrackingFileManager tfm = createTrackingFileManager(fs); - for (int i = 0; i < 100; i++) { + for (int i = 0; i < 1000; i++) { Path propFile = createTmpFile(fs); assertNotNull(tfm.read(propFile)); assertDoesNotThrow(() -> Files.delete(propFile), "Leaked file" + propFile); @@ -157,7 +157,7 @@ void testUpdateNoFileLeak(FS fs) throws Exception { Map updates = new HashMap<>(); updates.put("k", "v"); - for (int i = 0; i < 100; i++) { + for (int i = 0; i < 1000; i++) { Path propFile = createTmpFile(fs); assertNotNull(tfm.update(propFile, updates)); assertDoesNotThrow(() -> Files.delete(propFile), "Leaked file" + propFile); @@ -169,7 +169,7 @@ void testUpdateNoFileLeak(FS fs) throws Exception { public void testDeleteFileIsGone(FS fs) throws Exception { TrackingFileManager tfm = createTrackingFileManager(fs); - for (int i = 0; i < 100; i++) { + for (int i = 0; i < 1000; i++) { Path propFile = createTmpFile(fs); assertTrue(tfm.delete(propFile)); assertFalse(Files.exists(propFile), "File is not gone"); @@ -196,7 +196,7 @@ void testLockingOnCanonicalPath(FS fs) throws Exception { threads[i] = new Thread(() -> { try { - for (int i1 = 0; i1 < 100; i1++) { + for (int i1 = 0; i1 < 1000; i1++) { assertNotNull(tfm.read(file)); HashMap update = new HashMap<>(); update.put("wasHere", Thread.currentThread().getName() + "-" + i1); From 2495c373118a958c85c02ed4c03549793c7f6f50 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Mon, 31 Aug 2026 19:55:44 +0200 Subject: [PATCH 4/5] Reduce iterations in TrackingFileManagerTestSupport from 1000 to 100 to avoid exhausting OS file descriptors --- .../internal/impl/TrackingFileManagerTestSupport.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/TrackingFileManagerTestSupport.java b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/TrackingFileManagerTestSupport.java index a72f52cf69..214e4140de 100644 --- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/TrackingFileManagerTestSupport.java +++ b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/TrackingFileManagerTestSupport.java @@ -120,7 +120,7 @@ void testRead(FS fs) throws Exception { void testReadNoFileLeak(FS fs) throws Exception { TrackingFileManager tfm = createTrackingFileManager(fs); - for (int i = 0; i < 1000; i++) { + for (int i = 0; i < 100; i++) { Path propFile = createTmpFile(fs); assertNotNull(tfm.read(propFile)); assertDoesNotThrow(() -> Files.delete(propFile), "Leaked file" + propFile); @@ -157,7 +157,7 @@ void testUpdateNoFileLeak(FS fs) throws Exception { Map updates = new HashMap<>(); updates.put("k", "v"); - for (int i = 0; i < 1000; i++) { + for (int i = 0; i < 100; i++) { Path propFile = createTmpFile(fs); assertNotNull(tfm.update(propFile, updates)); assertDoesNotThrow(() -> Files.delete(propFile), "Leaked file" + propFile); @@ -169,7 +169,7 @@ void testUpdateNoFileLeak(FS fs) throws Exception { public void testDeleteFileIsGone(FS fs) throws Exception { TrackingFileManager tfm = createTrackingFileManager(fs); - for (int i = 0; i < 1000; i++) { + for (int i = 0; i < 100; i++) { Path propFile = createTmpFile(fs); assertTrue(tfm.delete(propFile)); assertFalse(Files.exists(propFile), "File is not gone"); @@ -196,7 +196,7 @@ void testLockingOnCanonicalPath(FS fs) throws Exception { threads[i] = new Thread(() -> { try { - for (int i1 = 0; i1 < 1000; i1++) { + for (int i1 = 0; i1 < 100; i1++) { assertNotNull(tfm.read(file)); HashMap update = new HashMap<>(); update.put("wasHere", Thread.currentThread().getName() + "-" + i1); From 8c73e0736d433a8900bbf1c8819382866e87bf4b Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Mon, 31 Aug 2026 20:26:39 +0200 Subject: [PATCH 5/5] Wrap namedLock.close() and close() in try-finally in NamedLockFactoryAdapter --- .../synccontext/named/NamedLockFactoryAdapter.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java index 88f86efdc2..acc0c8c3bf 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java @@ -258,15 +258,21 @@ public void acquire(Collection artifacts, Collection