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

Closes #12763
This commit is contained in:
Adrien Grand 2023-11-13 10:01:39 +01:00
parent 4e2ce76b3e
commit c081cfa0ba
1 changed files with 4 additions and 1 deletions

View File

@ -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