|
30 | 30 | import org.apache.lucene.document.Document; |
31 | 31 | import org.apache.lucene.document.Field; |
32 | 32 | import org.apache.lucene.index.IndexWriterConfig.OpenMode; |
| 33 | +import org.apache.lucene.store.AlreadyClosedException; |
33 | 34 | import org.apache.lucene.store.Directory; |
34 | 35 | import org.apache.lucene.store.IOContext; |
35 | 36 | import org.apache.lucene.store.IndexInput; |
|
41 | 42 | import org.apache.lucene.tests.util.TestUtil; |
42 | 43 | import org.apache.lucene.util.InfoStream; |
43 | 44 |
|
44 | | -/* |
45 | | - Verify we can read the pre-2.1 file format, do searches |
46 | | - against it, and add documents to it. |
47 | | -*/ |
48 | | - |
49 | 45 | public class TestIndexFileDeleter extends LuceneTestCase { |
50 | 46 |
|
51 | 47 | public void testDeleteLeftoverFiles() throws IOException { |
@@ -440,7 +436,6 @@ public void eval(MockDirectoryWrapper dir) throws IOException { |
440 | 436 | }); |
441 | 437 |
|
442 | 438 | IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random())); |
443 | | - // iwc.setMergeScheduler(new SerialMergeScheduler()); |
444 | 439 | MergeScheduler ms = iwc.getMergeScheduler(); |
445 | 440 | if (ms instanceof ConcurrentMergeScheduler) { |
446 | 441 | final ConcurrentMergeScheduler suppressFakeFail = |
@@ -486,8 +481,12 @@ protected void handleMergeException(Throwable exc) { |
486 | 481 | } |
487 | 482 | } catch (Throwable t) { |
488 | 483 | if (t.toString().contains("fake fail") |
489 | | - || (t.getCause() != null && t.getCause().toString().contains("fake fail"))) { |
490 | | - // ok |
| 484 | + || (t.getCause() != null && t.getCause().toString().contains("fake fail")) |
| 485 | + || t instanceof AlreadyClosedException) { |
| 486 | + // All these conditions are fine. |
| 487 | + // AlreadyClosedException can happen if the injected exception (RuntimeException("fake |
| 488 | + // fail")) happened inside the concurrent merges and this closed the index writer's |
| 489 | + // reader pool. |
491 | 490 | } else { |
492 | 491 | throw t; |
493 | 492 | } |
|
0 commit comments