Apache Lucene open-source search software
Allow AlreadyClosedException to be a possible outcome of injecting fake exceptions in TestIndexFileDeleter (#15545)
Dawid Weissf996e744c178
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.javaindex e62ca8235a2..68958107c5a 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java@@ -30,6 +30,7 @@ import org.apache.lucene.codecs.simpletext.SimpleTextCodec;import org.apache.lucene.document.Document;import org.apache.lucene.document.Field;import org.apache.lucene.index.IndexWriterConfig.OpenMode;+import org.apache.lucene.store.AlreadyClosedException;import org.apache.lucene.store.Directory;import org.apache.lucene.store.IOContext;import org.apache.lucene.store.IndexInput;@@ -41,11 +42,6 @@ import org.apache.lucene.tests.util.LuceneTestCase;import org.apache.lucene.tests.util.TestUtil;import org.apache.lucene.util.InfoStream;-/*- Verify we can read the pre-2.1 file format, do searches- against it, and add documents to it.-*/-public class TestIndexFileDeleter extends LuceneTestCase {public void testDeleteLeftoverFiles() throws IOException {@@ -440,7 +436,6 @@ public class TestIndexFileDeleter extends LuceneTestCase {});IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));- // iwc.setMergeScheduler(new SerialMergeScheduler());MergeScheduler ms = iwc.getMergeScheduler();if (ms instanceof ConcurrentMergeScheduler) {final ConcurrentMergeScheduler suppressFakeFail =@@ -486,8 +481,12 @@ public class TestIndexFileDeleter extends LuceneTestCase {}} catch (Throwable t) {if (t.toString().contains("fake fail")- || (t.getCause() != null && t.getCause().toString().contains("fake fail"))) {- // ok+ || (t.getCause() != null && t.getCause().toString().contains("fake fail"))+ || t instanceof AlreadyClosedException) {+ // All these conditions are fine.+ // AlreadyClosedException can happen if the injected exception (RuntimeException("fake+ // fail")) happened inside the concurrent merges and this closed the index writer's+ // reader pool.} else {throw t;}