From 98b31d86b2e183d15b965236bb32a89aee8314de Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 9 Jan 2014 20:31:40 +0000 Subject: [PATCH] LUCENE-5390: Loosen assert in IW on pending event after close git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1556942 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/lucene/index/IndexWriter.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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 {