You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2026/01/03 16:57:27 UTC

(lucene) branch main updated: Allow AlreadyClosedException to be a possible outcome of injecting fake exceptions in TestIndexFileDeleter (#15545)

This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new f996e744c17 Allow AlreadyClosedException to be a possible outcome of injecting fake exceptions in TestIndexFileDeleter (#15545)
f996e744c17 is described below

commit f996e744c1787da16454777a4dadc2f3cd2fac0a
Author: Dawid Weiss <da...@carrotsearch.com>
AuthorDate: Sat Jan 3 17:57:21 2026 +0100

    Allow AlreadyClosedException to be a possible outcome of injecting fake exceptions in TestIndexFileDeleter (#15545)
    
    * Allow AlreadyClosedException to be a possible outcome of injecting fake exceptions in TestIndexFileDeleter
    
    * Fix duplicate branches.
---
 .../org/apache/lucene/index/TestIndexFileDeleter.java     | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
index 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;
         }