Buggy code:
public void testVariableSchema ( ) throws Exception { } public void testUnlimitedMaxFieldLength ( ) throws IOException { } public void testEmptyFieldName ( ) throws IOException { } public void testEmptyFieldNameTerms ( ) throws IOException { } public void testEmptyFieldNameWithEmptyTerm ( ) throws IOException { } private static final class MockIndexWriter extends IndexWriter { public MockIndexWriter ( Directory dir , IndexWriterConfig conf ) throws IOException { } boolean afterWasCalled ; boolean beforeWasCalled ; @ Override public void doAfterFlush ( ) { } @ Override protected void doBeforeFlush ( ) { } } public void testDoBeforeAfterFlush ( ) throws IOException { } public void testNegativePositions ( ) throws Throwable { } public void testBinaryFieldOffsetLength ( ) throws IOException { } public void testPositionIncrementGapEmptyField ( ) throws Exception { } public void testDeadlock ( ) throws Exception { } private class IndexerThreadInterrupt extends Thread { volatile boolean failed ; volatile boolean finish ; volatile boolean allowInterrupt = false ; @ Override public void run ( ) { } } public void testThreadInterruptDeadlock ( ) throws Exception { } public void testIndexStoreCombos ( ) throws Exception { } public void testStoredFieldsOrder ( ) throws Throwable { } public void testNoDocsIndex ( ) throws Throwable { } public void testIndexDivisor ( ) throws Exception { } public void testDeleteUnusedFiles ( ) throws Exception { } public void testDeleteUnsedFiles2 ( ) throws Exception { } public void testEmptyFSDirWithNoLock ( ) throws Exception { } public void testEmptyDirRollback ( ) throws Exception { } public void testNoSegmentFile ( ) throws IOException { } public void testNoUnwantedTVFiles ( ) throws Exception { } static final class StringSplitAnalyzer extends Analyzer { @ Override public TokenStreamComponents createComponents ( String fieldName , Reader reader ) { } } private static class StringSplitTokenizer extends Tokenizer { private String [ ] tokens ; private int upto ; private final CharTermAttribute termAtt = addAttribute ( CharTermAttribute . class ) ; public StringSplitTokenizer ( Reader r ) { } @ Override public final boolean incrementToken ( ) { } @ Override public void reset ( ) throws IOException { } } public void testWickedLongTerm ( ) throws IOException { } public void testEmptyFieldNameTIIOne ( ) throws IOException { } public void testDeleteAllNRTLeftoverFiles ( ) throws Exception { } public void testNRTReaderVersion ( ) throws Exception { } public void testWhetherDeleteAllDeletesWriteLock ( ) throws Exception { } public void testChangeIndexOptions ( ) throws Exception { } public void testOnlyUpdateDocuments ( ) throws Exception { } public void testPrepareCommitThenClose ( ) throws Exception { } public void testPrepareCommitThenRollback ( ) throws Exception { } public void testPrepareCommitThenRollback2 ( ) throws Exception { } public void testDontInvokeAnalyzerForUnAnalyzedFields ( ) throws Exception { } public void testOtherFiles ( ) throws Throwable { } public void testOtherFiles2 ( ) throws Throwable { } public void testRotatingFieldNames ( ) throws Exception { } public void testCommitWithUserDataOnly ( ) throws Exception { } @ Test public void testGetCommitData ( ) throws Exception { } public void testIterableThrowsException ( ) throws IOException { Directory dir = newDirectory ( ) ; IndexWriter w = new IndexWriter ( dir , newIndexWriterConfig ( TEST_VERSION_CURRENT , new MockAnalyzer ( random ( ) ) ) ) ; int iters = atLeast ( 100 ) ; int docCount = 0 ; int docId = 0 ; Set < String > liveIds = new HashSet < String > ( ) ; for ( int i = 0 ; i < iters ; i ++ ) { List < Iterable < IndexableField > > docs = new ArrayList < Iterable < IndexableField > > ( ) ; FieldType ft = new FieldType ( TextField . TYPE_NOT_STORED ) ; FieldType idFt = new FieldType ( TextField . TYPE_STORED ) ; int numDocs = atLeast ( 4 ) ; for ( int j = 0 ; j < numDocs ; j ++ ) { Document doc = new Document ( ) ; doc . add ( newField ( "id" , ( "" + ( docId ++ ) ) , idFt ) ) ; doc . add ( newField ( "foo" , _TestUtil . randomSimpleString ( random ( ) ) , ft ) ) ; docs . add ( doc ) ; } boolean success = false ; try { w . addDocuments ( new TestIndexWriter . RandomFailingFieldIterable ( docs , random ( ) ) ) ; success = true ; } catch ( RuntimeException e ) { assertEquals ( "boom" , e . getMessage ( ) ) ; } finally { if ( success ) { docCount += docs . size ( ) ; for ( Iterable < IndexableField > indexDocument : docs ) { liveIds . add ( ( ( Document ) ( indexDocument ) ) . get ( "id" ) ) ; } } } } DirectoryReader reader = w . getReader ( ) ; assertEquals ( docCount , reader . numDocs ( ) ) ; List < AtomicReaderContext > leaves = reader . leaves ( ) ; for ( AtomicReaderContext atomicReaderContext : leaves ) { AtomicReader ar = atomicReaderContext . reader ( ) ; Bits liveDocs = ar . getLiveDocs ( ) ; int maxDoc = ar . maxDoc ( ) ; for ( int i = 0 ; i < maxDoc ; i ++ ) { <START_BUG> if ( liveDocs . get ( i ) ) { <END_BUG> assertTrue ( liveIds . remove ( ar . document ( i ) . get ( "id" ) ) ) ; } } } assertTrue ( liveIds . isEmpty ( ) ) ; IOUtils . close ( reader , w , dir ) ; } private static class RandomFailingFieldIterable implements Iterable < Iterable < IndexableField > > { private final List < Iterable < IndexableField > > docList ; private final Random random ; public RandomFailingFieldIterable ( List < Iterable < IndexableField > > docList , Random random ) { } @ Override public Iterator < Iterable < IndexableField > > iterator ( ) { } } }

Fix:
if ( ( liveDocs == null ) || ( liveDocs . get ( i ) ) ) {