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 { } public void testAddIndexes2 ( ) throws Exception { } public void testDeleteFromIndexWriter ( ) throws Exception { } public void testAddIndexesAndDoDeletesThreads ( ) throws Throwable { } 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 < Throwable > failures = new ArrayList < Throwable > ( ) ; IndexReader [ ] readers ; boolean didClose = false ; TestIndexWriterReader . HeavyAtomicInt count = new TestIndexWriterReader . HeavyAtomicInt ( 0 ) ; TestIndexWriterReader . HeavyAtomicInt numaddIndexes = 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 { Directory dir1 = new MockRAMDirectory ( ) ; TestIndexWriterReader . MyWarmer warmer = new TestIndexWriterReader . MyWarmer ( ) ; IndexWriter writer = new IndexWriter ( dir1 , new IndexWriterConfig ( TEST_VERSION_CURRENT , new org . apache . lucene . analysis . MockAnalyzer ( ) ) . setMaxBufferedDocs ( 2 ) . setMergedSegmentWarmer ( warmer ) ) ; writer . setInfoStream ( TestIndexWriterReader . infoStream ) ; TestIndexWriterReader . createIndexNoClose ( false , "test" , writer ) ; IndexReader r1 = writer . getReader ( ) ; ( ( LogMergePolicy ) ( writer . getConfig ( ) . getMergePolicy ( ) ) ) . setMergeFactor ( 2 ) ; <START_BUG> for ( int i = 0 ; i < 10 ; i ++ ) { <END_BUG> writer . addDocument ( TestIndexWriterReader . createDocument ( i , "test" , 4 ) ) ; } ( ( ConcurrentMergeScheduler ) ( writer . getConfig ( ) . getMergeScheduler ( ) ) ) . sync ( ) ; assertTrue ( ( ( warmer . warmCount ) > 0 ) ) ; final int count = warmer . warmCount ; writer . addDocument ( TestIndexWriterReader . createDocument ( 17 , "test" , 4 ) ) ; writer . optimize ( ) ; assertTrue ( ( ( warmer . warmCount ) > count ) ) ; writer . close ( ) ; r1 . close ( ) ; dir1 . close ( ) ; } 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 { } public void testDeletesNumDocs ( ) throws Throwable { } public void testEmptyIndex ( ) throws Exception { } public void testSegmentWarmer ( ) throws Exception { } }

Fix:
for ( int i = 0 ; i < ( 100 * ( _TestUtil . getRandomMultiplier ( ) ) ) ; i ++ ) {