Buggy code:
public class TestBackwardsCompatibility extends LuceneTestCase { public void unzip ( String zipName , String destDirName ) throws IOException { } public void testCreateCFS ( ) throws IOException { } public void testCreateNoCFS ( ) throws IOException { } final String [ ] oldNames = new String [ ] { "19.cfs" , "19.nocfs" , "20.cfs" , "20.nocfs" , "21.cfs" , "21.nocfs" , "22.cfs" , "22.nocfs" , "23.cfs" , "23.nocfs" } ; public void testOptimizeOldIndex ( ) throws IOException { } public void testSearchOldIndex ( ) throws IOException { } public void testIndexOldIndexNoAdds ( ) throws IOException { } public void testIndexOldIndex ( ) throws IOException { } private void testHits ( ScoreDoc [ ] hits , int expectedCount , IndexReader reader ) throws IOException { } public void searchIndex ( String dirName , String oldName ) throws IOException { } public void changeIndexWithAdds ( String dirName , boolean autoCommit ) throws IOException { } public void changeIndexNoAdds ( String dirName , boolean autoCommit ) throws IOException { } public void createIndex ( String dirName , boolean doCFS ) throws IOException { } public void testExactFileNames ( ) throws IOException { for ( int pass = 0 ; pass < 2 ; pass ++ ) { String outputDir = "lucene.backwardscompat0.index" ; rmDir ( outputDir ) ; try { Directory dir = FSDirectory . getDirectory ( TestBackwardsCompatibility . fullDir ( outputDir ) ) ; boolean autoCommit = 0 == pass ; IndexWriter writer = new IndexWriter ( dir , autoCommit , new WhitespaceAnalyzer ( ) , true ) ; writer . setRAMBufferSizeMB ( 16.0 ) ; for ( int i = 0 ; i < 35 ; i ++ ) { addDoc ( writer , i ) ; } assertEquals ( "wrong<seq2seq4repair_space>doc<seq2seq4repair_space>count" , 35 , writer . docCount ( ) ) ; writer . close ( ) ; IndexReader reader = IndexReader . open ( dir ) ; Term searchTerm = new Term ( "id" , "7" ) ; int delCount = reader . deleteDocuments ( searchTerm ) ; assertEquals ( "didn't<seq2seq4repair_space>delete<seq2seq4repair_space>the<seq2seq4repair_space>right<seq2seq4repair_space>number<seq2seq4repair_space>of<seq2seq4repair_space>documents" , 1 , delCount ) ; reader . setNorm ( 21 , "content" , ( ( float ) ( 1.5 ) ) ) ; reader . close ( ) ; CompoundFileReader cfsReader = new CompoundFileReader ( dir , "_0.cfs" ) ; FieldInfos fieldInfos = new FieldInfos ( cfsReader , "_0.fnm" ) ; int contentFieldIndex = - 1 ; for ( int i = 0 ; i < ( fieldInfos . size ( ) ) ; i ++ ) { FieldInfo fi = fieldInfos . fieldInfo ( i ) ; if ( fi . name . equals ( "content" ) ) { contentFieldIndex = i ; break ; } } cfsReader . close ( ) ; assertTrue ( "could<seq2seq4repair_space>not<seq2seq4repair_space>locate<seq2seq4repair_space>the<seq2seq4repair_space>'content'<seq2seq4repair_space>field<seq2seq4repair_space>number<seq2seq4repair_space>in<seq2seq4repair_space>the<seq2seq4repair_space>_2.cfs<seq2seq4repair_space>segment" , ( contentFieldIndex != ( - 1 ) ) ) ; String [ ] expected ; expected = new String [ ] { "_0.cfs" , "_0_1.del" , "_0_1.s" + contentFieldIndex , "segments_3" , "segments.gen" } ; <START_BUG> String [ ] actual = dir . list ( ) ; <END_BUG> Arrays . sort ( expected ) ; Arrays . sort ( actual ) ; if ( ! ( Arrays . equals ( expected , actual ) ) ) { fail ( ( ( ( "incorrect<seq2seq4repair_space>filenames<seq2seq4repair_space>in<seq2seq4repair_space>index:<seq2seq4repair_space>expected:\n<seq2seq4repair_space>" + ( asString ( expected ) ) ) + "\n<seq2seq4repair_space>actual:\n<seq2seq4repair_space>" ) + ( asString ( actual ) ) ) ) ; } dir . close ( ) ; } finally { rmDir ( outputDir ) ; } } } private String asString ( String [ ] l ) { } private void addDoc ( IndexWriter writer , int id ) throws IOException { } private void rmDir ( String dir ) throws IOException { } public static String fullDir ( String dirName ) throws IOException { } }

Fix:
String [ ] actual = dir . listAll ( ) ;