diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java index f9524768dff..b3d7d521e14 100644 --- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java +++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java @@ -930,10 +930,20 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{ closeInternal(waitForMerges, true); } } - assert eventQueue.isEmpty(); + assert assertEventQueueAfterClose(); } } + private boolean assertEventQueueAfterClose() { + if (eventQueue.isEmpty()) { + return true; + } + for (Event e : eventQueue) { + assert e instanceof DocumentsWriter.MergePendingEvent : e; + } + return true; + } + // Returns true if this thread should attempt to close, or // false if IndexWriter is now closed; else, waits until // another thread finishes closing @@ -2022,7 +2032,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{ rollbackInternal(); } } - assert eventQueue.isEmpty() : eventQueue; + assert assertEventQueueAfterClose(); } private void rollbackInternal() throws IOException {