This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch fix-flaky-awaitIdle
in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git

commit ede27b48d17fde1eb40d376231f24b2bba1fc47c
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue Mar 17 08:23:24 2026 +0100

    Fix flaky awaitIdle in integration tests
    
    The awaitIdle() method had two problems causing flaky test failures
    (especially on macOS ARM64 CI runners):
    
    1. Tight busy-loop with no sleep - spins continuously on getAll()
       which acquires a file lock each iteration, causing contention
       and wasted CPU
    2. 5000ms timeout too short for CI environments under load
    
    Fix by adding a 100ms sleep between polls and increasing the timeout
    to 30 seconds.
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
 .../src/test/java/org/mvndaemon/mvnd/junit/TestRegistry.java      | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git 
a/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/TestRegistry.java 
b/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/TestRegistry.java
index cffeb18b..33fd782f 100644
--- a/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/TestRegistry.java
+++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/TestRegistry.java
@@ -72,7 +72,7 @@ public class TestRegistry extends DaemonRegistry {
      * @throws AssertionError        if the timeout is exceeded
      */
     public void awaitIdle(String daemonId) {
-        final int timeoutMs = 5000;
+        final int timeoutMs = 30_000;
         final long deadline = System.currentTimeMillis() + timeoutMs;
         while (getAll().stream()
                         .filter(di -> di.getId().equals(daemonId))
@@ -84,6 +84,12 @@ public class TestRegistry extends DaemonRegistry {
             Assertions.assertThat(deadline)
                     .withFailMessage("Daemon %s should have become idle within 
%d", daemonId, timeoutMs)
                     .isGreaterThan(System.currentTimeMillis());
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
+                throw new RuntimeException(e);
+            }
         }
     }
 }

Reply via email to