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:13:38 UTC
(jackrabbit-oak) branch trunk updated: OAK-12421 - ForkJoinUtilsTest can be flaky (#3177)
This is an automated email from the ASF dual-hosted git repository.
jsedding pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new cf805f8f13 OAK-12421 - ForkJoinUtilsTest can be flaky (#3177)
cf805f8f13 is described below
commit cf805f8f138f491d82eec57c6405aa492dc4abd3
Author: Julian Sedding <js...@apache.org>
AuthorDate: Tue Sep 29 12:13:31 2026 +0200
OAK-12421 - ForkJoinUtilsTest can be flaky (#3177)
- 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)