From c081cfa0bae3b421126219f9394aaa2c3555ba3d Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Mon, 13 Nov 2023 10:01:39 +0100 Subject: [PATCH] Use a serial merge scheduler to avoid race conditions when checking for hasPendingMerges(). Closes #12763 --- .../src/test/org/apache/lucene/index/TestIndexWriter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java index bd71fedb05e..f63a1ee6aef 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java @@ -2372,7 +2372,10 @@ public class TestIndexWriter extends LuceneTestCase { public void testHasUncommittedChanges() throws IOException { Directory dir = newDirectory(); - IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random()))); + IndexWriter writer = new IndexWriter(dir, + newIndexWriterConfig(new MockAnalyzer(random())) + // Use a serial merge scheduler to avoid race conditions when checking for hasPendingMerges() + .setMergeScheduler(new SerialMergeScheduler())); assertTrue( writer.hasUncommittedChanges()); // this will be true because a commit will create an empty // index