Skip to content

Apache Lucene open-source search software

Use a serial merge scheduler to avoid race conditions when checking for hasPendingMerges().

Adrien Grandc081cfa0bae3
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