Buggy code:
public class TestIndexWriterReader extends LuceneTestCase { static PrintStream infoStream ; public static class HeavyAtomicInt { private int value ; public HeavyAtomicInt ( int start ) { } public synchronized int addAndGet ( int inc ) { } public synchronized int incrementAndGet ( ) { } public synchronized int intValue ( ) { } } public static int count ( Term t , IndexReader r ) throws IOException { } public void testUpdateDocument ( ) throws Exception { } public void testAddIndexes ( ) throws Exception { boolean optimize = false ; Directory dir1 = new MockRAMDirectory ( ) ; IndexWriter writer = new IndexWriter ( dir1 , new WhitespaceAnalyzer ( ) , MaxFieldLength . LIMITED ) ; writer . setInfoStream ( TestIndexWriterReader . infoStream ) ; TestIndexWriterReader . createIndexNoClose ( ( ! optimize ) , "index1" , writer ) ; writer . flush ( false , true , true ) ; Directory dir2 = new MockRAMDirectory ( ) ; IndexWriter writer2 = new IndexWriter ( dir2 , new WhitespaceAnalyzer ( ) , MaxFieldLength . LIMITED ) ; writer2 . setInfoStream ( TestIndexWriterReader . infoStream ) ; TestIndexWriterReader . createIndexNoClose ( ( ! optimize ) , "index2" , writer2 ) ; writer2 . close ( ) ; IndexReader r0 = writer . getReader ( ) ; assertTrue ( r0 . isCurrent ( ) ) ; writer . addIndexesNoOptimize ( new Directory [ ] { dir2 } ) ; assertFalse ( r0 . isCurrent ( ) ) ; r0 . close ( ) ; IndexReader r1 = writer . getReader ( ) ; assertTrue ( r1 . isCurrent ( ) ) ; writer . commit ( ) ; <START_BUG> assertFalse ( r1 . isCurrent ( ) ) ; <END_BUG> assertEquals ( 200 , r1 . maxDoc ( ) ) ; int index2df = r1 . docFreq ( new Term ( "indexname" , "index2" ) ) ; assertEquals ( 100 , index2df ) ; Document doc5 = r1 . document ( 5 ) ; assertEquals ( "index1" , doc5 . get ( "indexname" ) ) ; Document doc150 = r1 . document ( 150 ) ; assertEquals ( "index2" , doc150 . get ( "indexname" ) ) ; r1 . close ( ) ; writer . close ( ) ; dir1 . close ( ) ; } public void testAddIndexes2 ( ) throws Exception { } public void testDeleteFromIndexWriter ( ) throws Exception { } public void testAddIndexesAndDoDeletesThreads ( ) throws Throwable { } private class DeleteThreads { static final int NUM_THREADS = 5 ; final Thread [ ] threads = new Thread [ TestIndexWriterReader . DeleteThreads . NUM_THREADS ] ; IndexWriter mainWriter ; List deletedTerms = new ArrayList ( ) ; LinkedList toDeleteTerms = new LinkedList ( ) ; Random random ; final List failures = new ArrayList ( ) ; public DeleteThreads ( IndexWriter mainWriter ) throws IOException { } Term getDeleteTerm ( ) { } void launchThreads ( final int numIter ) { } void handle ( Throwable t ) { } void joinThreads ( ) { } } private class AddDirectoriesThreads { Directory addDir ; static final int NUM_THREADS = 5 ; static final int NUM_INIT_DOCS = 100 ; int numDirs ; final Thread [ ] threads = new Thread [ TestIndexWriterReader . AddDirectoriesThreads . NUM_THREADS ] ; IndexWriter mainWriter ; final List failures = new ArrayList ( ) ; IndexReader [ ] readers ; boolean didClose = false ; TestIndexWriterReader . HeavyAtomicInt count = new TestIndexWriterReader . HeavyAtomicInt ( 0 ) ; TestIndexWriterReader . HeavyAtomicInt numAddIndexesNoOptimize = new TestIndexWriterReader . HeavyAtomicInt ( 0 ) ; public AddDirectoriesThreads ( int numDirs , IndexWriter mainWriter ) throws Throwable { } void joinThreads ( ) { } void close ( boolean doWait ) throws Throwable { } void closeDir ( ) throws Throwable { } void handle ( Throwable t ) { } void launchThreads ( final int numIter ) { } void doBody ( int j , Directory [ ] dirs ) throws Throwable { } } public void testIndexWriterReopenSegmentOptimize ( ) throws Exception { } public void testIndexWriterReopenSegment ( ) throws Exception { } public void doTestIndexWriterReopenSegment ( boolean optimize ) throws Exception { } public static Document createDocument ( int n , String indexName , int numFields ) { } public static void createIndex ( Directory dir1 , String indexName , boolean multiSegment ) throws IOException { } public static void createIndexNoClose ( boolean multiSegment , String indexName , IndexWriter w ) throws IOException { } private static class MyWarmer extends IndexWriter . IndexReaderWarmer { int warmCount ; @ Override public void warm ( IndexReader reader ) throws IOException { } } public void testMergeWarmer ( ) throws Exception { } public void testAfterCommit ( ) throws Exception { } public void testAfterClose ( ) throws Exception { } public void testDuringAddIndexes ( ) throws Exception { } public void testDuringAddDelete ( ) throws Exception { } public void testExpungeDeletes ( ) throws Throwable { } }

Fix:
assertTrue ( r1 . isCurrent ( ) ) ;