diff --git a/lucene/misc/src/java/org/apache/lucene/misc/index/BPIndexReorderer.java b/lucene/misc/src/java/org/apache/lucene/misc/index/BPIndexReorderer.java index 9b61c58e7f1..52f1e646ccf 100644 --- a/lucene/misc/src/java/org/apache/lucene/misc/index/BPIndexReorderer.java +++ b/lucene/misc/src/java/org/apache/lucene/misc/index/BPIndexReorderer.java @@ -74,7 +74,9 @@ import org.apache.lucene.util.OfflineSorter.BufferSize; * * Directory targetDir = FSDirectory.open(targetPath); * BPIndexReorderer reorderer = new BPIndexReorderer(); - * reorderer.setForkJoinPool(ForkJoinPool.commonPool()); + * ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), + * p -> new ForkJoinWorkerThread(p) {}, null, random().nextBoolean()); + * reorderer.setForkJoinPool(pool); * reorderer.setFields(Collections.singleton("body")); * CodecReader reorderedReaderView = reorderer.reorder(SlowCodecReaderWrapper.wrap(reader), targetDir); * try (IndexWriter w = new IndexWriter(targetDir, new IndexWriterConfig().setOpenMode(OpenMode.CREATE))) { diff --git a/lucene/misc/src/test/org/apache/lucene/misc/index/TestBPIndexReorderer.java b/lucene/misc/src/test/org/apache/lucene/misc/index/TestBPIndexReorderer.java index 4b6a9a85037..13d6989ff74 100644 --- a/lucene/misc/src/test/org/apache/lucene/misc/index/TestBPIndexReorderer.java +++ b/lucene/misc/src/test/org/apache/lucene/misc/index/TestBPIndexReorderer.java @@ -21,6 +21,7 @@ import static org.apache.lucene.misc.index.BPIndexReorderer.fastLog2; import java.io.IOException; import java.util.Arrays; import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.ForkJoinWorkerThread; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field.Store; import org.apache.lucene.document.StoredField; @@ -47,7 +48,11 @@ public class TestBPIndexReorderer extends LuceneTestCase { public void testSingleTermWithForkJoinPool() throws IOException { int concurrency = TestUtil.nextInt(random(), 1, 8); - ForkJoinPool pool = new ForkJoinPool(concurrency); + // The default ForkJoinPool implementation uses a thread factory that removes all permissions on + // threads, so we need to create our own to avoid tests failing with FS-based directories. + ForkJoinPool pool = + new ForkJoinPool( + concurrency, p -> new ForkJoinWorkerThread(p) {}, null, random().nextBoolean()); try { doTestSingleTerm(pool); } finally {