Use fair locks 48/110448/4
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 3 Mar 2024 06:53:33 +0000 (07:53 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 3 Mar 2024 07:07:45 +0000 (08:07 +0100)
When we are contended, we should try and execute tests on a first-come
first-serve basis.

JIRA: ODLPARENT-262
Change-Id: I68e45bb9d0f59130083c188c19617e1a91636234
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/TestFeaturesMojo.java

index e685c2b89164058d531a2f1ac21aafb3d40e9310..d86234bfbfd07583eb44b05377f54760388d8b58 100644 (file)
@@ -178,7 +178,8 @@ public final class TestFeaturesMojo extends AbstractMojo {
             topContext = session.getPluginContext(STATIC_DESCRIPTOR, session.getTopLevelProject());
         }
 
-        final var lock = (Lock) topContext.computeIfAbsent("lock", key -> new ReentrantLock());
+        // Note: we are using a fair lock to get first-come, first-serve rather than some unpredictable order
+        final var lock = (Lock) topContext.computeIfAbsent("lock", key -> new ReentrantLock(true));
         LOG.debug("Using lock {}", lock);
         try {
             lock.lockInterruptibly();