You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by js...@apache.org on 2026/09/29 10:11:16 UTC

(jackrabbit-oak) branch OAK-12421-flaky-ForkJoinUtilsTest created (now 6c2a217712)

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

jsedding pushed a change to branch OAK-12421-flaky-ForkJoinUtilsTest
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git


      at 6c2a217712 OAK-12421 - ForkJoinUtilsTest can be flaky

This branch includes the following new commits:

     new 6c2a217712 OAK-12421 - ForkJoinUtilsTest can be flaky

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(jackrabbit-oak) 01/01: OAK-12421 - ForkJoinUtilsTest can be flaky

Posted by js...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jsedding pushed a commit to branch OAK-12421-flaky-ForkJoinUtilsTest
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git

commit 6c2a217712e498a27307f14992a1f7564740b964
Author: Julian Sedding <js...@apache.org>
AuthorDate: Tue Sep 29 12:10:58 2026 +0200

    OAK-12421 - ForkJoinUtilsTest can be flaky
    
    - final attempt at fixing flaky test
---
 .../internal/concurrent/ForkJoinUtilsTest.java     | 23 ++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/internal/concurrent/ForkJoinUtilsTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/internal/concurrent/ForkJoinUtilsTest.java
index e740475e13..107f136a17 100644
--- a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/internal/concurrent/ForkJoinUtilsTest.java
+++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/internal/concurrent/ForkJoinUtilsTest.java
@@ -27,20 +27,39 @@ import java.util.Map;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assume.assumeTrue;
 
 public class ForkJoinUtilsTest {
 
     @Test
     public void isInCommonPool() {
+        int parallelism = ForkJoinPool.commonPool().getParallelism();
+        assumeTrue(
+                "Expected ForkJoinPool.commonPool() to have parallelism greater than 2, was " + parallelism,
+                parallelism > 2);
+
         Map<Integer, String> results = getParallelTestStream()
                 .boxed()
-                .map(i -> Map.entry(i, isInCommonPool(Thread.currentThread())
-                        ? "common" : Thread.currentThread().getName()))
+                .map(i -> {
+                    String threadLabel;
+                    if (isInCommonPool(Thread.currentThread())) {
+                        threadLabel = "common";
+                    } else {
+                        threadLabel = Thread.currentThread().getName();
+                        try {
+                            TimeUnit.MILLISECONDS.sleep(10);
+                        } catch (InterruptedException e) {
+                            Thread.currentThread().interrupt();
+                        }
+                    }
+                    return Map.entry(i, threadLabel);
+                })
                 .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
         assertThat(results)
                 .hasSize(10)