From bd004d2c5763052f74a930caa279ffdb41d2a9a6 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Mon, 11 May 2020 17:46:50 +0200 Subject: [PATCH] Fix test to check for close / closing and wait for merge threads to close the writer if concurrency strikes --- .../apache/lucene/index/TestConcurrentMergeScheduler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lucene/core/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java b/lucene/core/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java index 050aed7864a..a31194caf7a 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java @@ -113,9 +113,13 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase { ioe.printStackTrace(System.out); } failure.clearDoFail(); - assertTrue(writer.isClosed()); + // make sure we are closed or closing - if we are unlucky a merge does + // the actual closing for us. this is rare but might happen since the + // tragicEvent is checked by IFD and that might throw during a merge + expectThrows(AlreadyClosedException.class, writer::ensureOpen); // Abort should have closed the deleter: assertTrue(writer.isDeleterClosed()); + writer.close(); // now wait for the close to actually happen if a merge thread did the close. break outer; } }