Buggy code:
public class TestIndexWriterDelete extends LuceneTestCase { public void testSimpleCase ( ) throws IOException { } public void testNonRAMDelete ( ) throws IOException { } public void testMaxBufferedDeletes ( ) throws IOException { } public void testRAMDeletes ( ) throws IOException { } public void testBothDeletes ( ) throws IOException { } public void testBatchDeletes ( ) throws IOException { } public void testDeleteAll ( ) throws IOException { } public void testDeleteAllRollback ( ) throws IOException { } public void testDeleteAllNRT ( ) throws IOException { } private void updateDoc ( IndexWriter modifier , int id , int value ) throws IOException { } private void addDoc ( IndexWriter modifier , int id , int value ) throws IOException { } private int getHitCount ( Directory dir , Term term ) throws IOException { } public void testDeletesOnDiskFull ( ) throws IOException { } public void testUpdatesOnDiskFull ( ) throws IOException { } private void doTestOperationsOnDiskFull ( boolean updates ) throws IOException { } public void testErrorAfterApplyDeletes ( ) throws IOException { } public void testErrorInDocsWriterAdd ( ) throws IOException { MockDirectoryWrapper . Failure failure = new MockDirectoryWrapper . Failure ( ) { boolean failed = false ; @ Override public Failure reset ( ) { failed = false ; return this ; } @ Override public void eval ( MockDirectoryWrapper dir ) throws IOException { if ( ! ( failed ) ) { failed = true ; throw new IOException ( "fail<seq2seq4repair_space>in<seq2seq4repair_space>add<seq2seq4repair_space>doc" ) ; } } } ; String [ ] keywords = new String [ ] { "1" , "2" } ; String [ ] unindexed = new String [ ] { "Netherlands" , "Italy" } ; String [ ] unstored = new String [ ] { "Amsterdam<seq2seq4repair_space>has<seq2seq4repair_space>lots<seq2seq4repair_space>of<seq2seq4repair_space>bridges" , "Venice<seq2seq4repair_space>has<seq2seq4repair_space>lots<seq2seq4repair_space>of<seq2seq4repair_space>canals" } ; String [ ] text = new String [ ] { "Amsterdam" , "Venice" } ; MockDirectoryWrapper dir = newDirectory ( ) ; IndexWriter modifier = new IndexWriter ( dir , newIndexWriterConfig ( TEST_VERSION_CURRENT , new org . apache . lucene . analysis . MockAnalyzer ( random , MockTokenizer . WHITESPACE , false ) ) ) ; modifier . commit ( ) ; dir . failOn ( failure . reset ( ) ) ; for ( int i = 0 ; i < ( keywords . length ) ; i ++ ) { Document doc = new Document ( ) ; doc . add ( newField ( "id" , keywords [ i ] , YES , NOT_ANALYZED ) ) ; doc . add ( newField ( "country" , unindexed [ i ] , YES , NO ) ) ; doc . add ( newField ( "contents" , unstored [ i ] , Field . Store . NO , ANALYZED ) ) ; doc . add ( newField ( "city" , text [ i ] , YES , ANALYZED ) ) ; try { modifier . addDocument ( doc ) ; } catch ( IOException io ) { if ( VERBOSE ) { System . out . println ( "TEST:<seq2seq4repair_space>got<seq2seq4repair_space>expected<seq2seq4repair_space>exc:" ) ; io . printStackTrace ( System . out ) ; } break ; } } String [ ] startFiles = dir . listAll ( ) ; SegmentInfos infos = new SegmentInfos ( ) ; infos . read ( dir ) ; <START_BUG> new IndexFileDeleter ( dir , new KeepOnlyLastCommitDeletionPolicy ( ) , infos , null ) ; <END_BUG> String [ ] endFiles = dir . listAll ( ) ; modifier . close ( ) ; dir . close ( ) ; if ( ! ( Arrays . equals ( startFiles , endFiles ) ) ) { fail ( ( ( ( "docswriter<seq2seq4repair_space>abort()<seq2seq4repair_space>failed<seq2seq4repair_space>to<seq2seq4repair_space>delete<seq2seq4repair_space>unreferenced<seq2seq4repair_space>files:\n<seq2seq4repair_space>before<seq2seq4repair_space>delete:\n<seq2seq4repair_space>" + ( arrayToString ( startFiles ) ) ) + "\n<seq2seq4repair_space>after<seq2seq4repair_space>delete:\n<seq2seq4repair_space>" ) + ( arrayToString ( endFiles ) ) ) ) ; } modifier . close ( ) ; } private String arrayToString ( String [ ] l ) { } public void testDeleteAllSlowly ( ) throws Exception { } public void testIndexingThenDeleting ( ) throws Exception { } public void testFlushPushedDeletesByRAM ( ) throws Exception { } public void testFlushPushedDeletesByCount ( ) throws Exception { } public void testApplyDeletesOnFlush ( ) throws Exception { } }

Fix:
new IndexFileDeleter ( dir , new KeepOnlyLastCommitDeletionPolicy ( ) , infos , null , null ) ;