mirror of https://github.com/apache/lucene.git
Fix issues with BP tests and the security manager. (#12568)
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.
This commit is contained in:
parent
ebfbc831ab
commit
36432fa672
|
@ -74,7 +74,9 @@ import org.apache.lucene.util.OfflineSorter.BufferSize;
|
||||||
*
|
*
|
||||||
* Directory targetDir = FSDirectory.open(targetPath);
|
* Directory targetDir = FSDirectory.open(targetPath);
|
||||||
* BPIndexReorderer reorderer = new BPIndexReorderer();
|
* 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"));
|
* reorderer.setFields(Collections.singleton("body"));
|
||||||
* CodecReader reorderedReaderView = reorderer.reorder(SlowCodecReaderWrapper.wrap(reader), targetDir);
|
* CodecReader reorderedReaderView = reorderer.reorder(SlowCodecReaderWrapper.wrap(reader), targetDir);
|
||||||
* try (IndexWriter w = new IndexWriter(targetDir, new IndexWriterConfig().setOpenMode(OpenMode.CREATE))) {
|
* try (IndexWriter w = new IndexWriter(targetDir, new IndexWriterConfig().setOpenMode(OpenMode.CREATE))) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import static org.apache.lucene.misc.index.BPIndexReorderer.fastLog2;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
|
import java.util.concurrent.ForkJoinWorkerThread;
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
import org.apache.lucene.document.Field.Store;
|
import org.apache.lucene.document.Field.Store;
|
||||||
import org.apache.lucene.document.StoredField;
|
import org.apache.lucene.document.StoredField;
|
||||||
|
@ -47,7 +48,11 @@ public class TestBPIndexReorderer extends LuceneTestCase {
|
||||||
|
|
||||||
public void testSingleTermWithForkJoinPool() throws IOException {
|
public void testSingleTermWithForkJoinPool() throws IOException {
|
||||||
int concurrency = TestUtil.nextInt(random(), 1, 8);
|
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 {
|
try {
|
||||||
doTestSingleTerm(pool);
|
doTestSingleTerm(pool);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue