Buggy code:
fieldsToUse = TestPostingsFormat . fieldsLive ; if ( VERBOSE ) { System . out . println ( "<seq2seq4repair_space>use<seq2seq4repair_space>liveDocs" ) ; } } else { liveDocs = null ; fieldsToUse = TestPostingsFormat . fields ; if ( VERBOSE ) { System . out . println ( "<seq2seq4repair_space>no<seq2seq4repair_space>liveDocs" ) ; } } FieldInfo fieldInfo = currentFieldInfos . fieldInfo ( field ) ; assertEquals ( TestPostingsFormat . fields . get ( field ) . get ( term ) . size ( ) , termsEnum . docFreq ( ) ) ; List < TestPostingsFormat . Posting > expected = fieldsToUse . get ( field ) . get ( term ) ; boolean allowFreqs = ( ( fieldInfo . getIndexOptions ( ) . compareTo ( DOCS_AND_FREQS ) ) >= 0 ) && ( ( maxIndexOptions . compareTo ( DOCS_AND_FREQS ) ) >= 0 ) ; boolean doCheckFreqs = allowFreqs && ( ( random ( ) . nextInt ( 3 ) ) <= 2 ) ; boolean allowPositions = ( ( fieldInfo . getIndexOptions ( ) . compareTo ( DOCS_AND_FREQS_AND_POSITIONS ) ) >= 0 ) && ( ( maxIndexOptions . compareTo ( DOCS_AND_FREQS_AND_POSITIONS ) ) >= 0 ) ; boolean doCheckPositions = allowPositions && ( ( random ( ) . nextInt ( 3 ) ) <= 2 ) ; boolean allowOffsets = ( ( fieldInfo . getIndexOptions ( ) . compareTo ( DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS ) ) >= 0 ) && ( ( maxIndexOptions . compareTo ( DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS ) ) >= 0 ) ; boolean doCheckOffsets = allowOffsets && ( ( random ( ) . nextInt ( 3 ) ) <= 2 ) ; boolean doCheckPayloads = ( ( options . contains ( TestPostingsFormat . Option . PAYLOADS ) ) && allowPositions ) && ( fieldInfo . hasPayloads ( ) ) ; DocsEnum prevDocsEnum = null ; DocsEnum docsEnum ; DocsAndPositionsEnum docsAndPositionsEnum ; if ( ! doCheckPositions ) { if ( allowPositions && ( ( random ( ) . nextInt ( 10 ) ) == 7 ) ) { if ( VERBOSE ) { System . out . println ( "<seq2seq4repair_space>get<seq2seq4repair_space>DocsAndPositionsEnum<seq2seq4repair_space>(but<seq2seq4repair_space>we<seq2seq4repair_space>won't<seq2seq4repair_space>check<seq2seq4repair_space>positions)" ) ; } if ( ( options . contains ( TestPostingsFormat . Option . REUSE_ENUMS ) ) && ( ( random ( ) . nextInt ( 10 ) ) < 9 ) ) { prevDocsEnum = threadState . reuseDocsAndPositionsEnum ; } threadState . reuseDocsAndPositionsEnum = termsEnum . docsAndPositions ( liveDocs , ( ( DocsAndPositionsEnum ) ( prevDocsEnum ) ) , false ) ; docsEnum = threadState . reuseDocsAndPositionsEnum ; docsAndPositionsEnum = threadState . reuseDocsAndPositionsEnum ; } else { if ( VERBOSE ) { System . out . println ( "<seq2seq4repair_space>get<seq2seq4repair_space>DocsEnum" ) ; } if ( ( options . contains ( TestPostingsFormat . Option . REUSE_ENUMS ) ) && ( ( random ( ) . nextInt ( 10 ) ) < 9 ) ) { prevDocsEnum = threadState . reuseDocsEnum ; } threadState . reuseDocsEnum = termsEnum . docs ( liveDocs , prevDocsEnum , doCheckFreqs ) ; docsEnum = threadState . reuseDocsEnum ; docsAndPositionsEnum = null ; } } else { if ( VERBOSE ) { System . out . println ( "<seq2seq4repair_space>get<seq2seq4repair_space>DocsAndPositionsEnum" ) ; } if ( ( options . contains ( TestPostingsFormat . Option . REUSE_ENUMS ) ) && ( ( random ( ) . nextInt ( 10 ) ) < 9 ) ) { prevDocsEnum = threadState . reuseDocsAndPositionsEnum ; } threadState . reuseDocsAndPositionsEnum = termsEnum . docsAndPositions ( liveDocs , ( ( DocsAndPositionsEnum ) ( prevDocsEnum ) ) , doCheckOffsets ) ; docsEnum = threadState . reuseDocsAndPositionsEnum ; docsAndPositionsEnum = threadState . reuseDocsAndPositionsEnum ; } assertNotNull ( "null<seq2seq4repair_space>DocsEnum" , docsEnum ) ; int initialDocID = docsEnum . docID ( ) ; <START_BUG> assertTrue ( "inital<seq2seq4repair_space>docID<seq2seq4repair_space>should<seq2seq4repair_space>be<seq2seq4repair_space>-1<seq2seq4repair_space>or<seq2seq4repair_space>NO_MORE_DOCS" , ( ( initialDocID == ( - 1 ) ) || ( initialDocID == ( DocsEnum . NO_MORE_DOCS ) ) ) ) ; <END_BUG> if ( VERBOSE ) { if ( prevDocsEnum == null ) { System . out . println ( ( "<seq2seq4repair_space>got<seq2seq4repair_space>enum=" + docsEnum ) ) ; } else if ( prevDocsEnum == docsEnum ) { System . out . println ( ( "<seq2seq4repair_space>got<seq2seq4repair_space>reuse<seq2seq4repair_space>enum=" + docsEnum ) ) ; } else { System . out . println ( ( ( ( ( "<seq2seq4repair_space>got<seq2seq4repair_space>enum=" + docsEnum ) + "<seq2seq4repair_space>(reuse<seq2seq4repair_space>of<seq2seq4repair_space>" ) + prevDocsEnum ) + "<seq2seq4repair_space>failed)" ) ) ; } } int stopAt ; if ( ( ( options . contains ( TestPostingsFormat . Option . PARTIAL_DOC_CONSUME ) ) && ( ( expected . size ( ) ) > 1 ) ) && ( ( random ( ) . nextInt ( 10 ) ) == 7 ) ) { stopAt = random ( ) . nextInt ( ( ( expected . size ( ) ) - 1 ) ) ; if ( VERBOSE ) { System . out . println ( ( ( ( ( "<seq2seq4repair_space>will<seq2seq4repair_space>not<seq2seq4repair_space>consume<seq2seq4repair_space>all<seq2seq4repair_space>docs<seq2seq4repair_space>(" + stopAt ) + "<seq2seq4repair_space>vs<seq2seq4repair_space>" ) + ( expected . size ( ) ) ) + ")" ) ) ; } } else { stopAt = expected . size ( ) ; if ( VERBOSE ) { System . out . println ( "<seq2seq4repair_space>consume<seq2seq4repair_space>all<seq2seq4repair_space>docs" ) ; } } double skipChance = random ( ) . nextDouble ( ) ; int numSkips = ( ( expected . size ( ) ) < 3 ) ? 1 : _TestUtil . nextInt ( random ( ) , 1 , Math . min ( 20 , ( ( expected . size ( ) ) // 3 ) ) ) ; int skipInc = ( expected . size ( ) ) // numSkips ; int skipDocInc = ( 1 + ( TestPostingsFormat . maxDocID ) ) // numSkips ; boolean doAllSkipping = ( options . contains ( TestPostingsFormat . Option . SKIPPING ) ) && ( ( random ( ) . nextInt ( 7 ) ) == 1 ) ; double freqAskChance = random ( ) . nextDouble ( ) ; double payloadCheckChance = random ( ) . nextDouble ( ) ; double offsetCheckChance = random ( ) . nextDouble ( ) ;

Fix:
assertTrue ( ( "inital<seq2seq4repair_space>docID<seq2seq4repair_space>should<seq2seq4repair_space>be<seq2seq4repair_space>-1<seq2seq4repair_space>or<seq2seq4repair_space>NO_MORE_DOCS:<seq2seq4repair_space>" + docsEnum ) , ( ( initialDocID == ( - 1 ) ) || ( initialDocID == ( DocsEnum . NO_MORE_DOCS ) ) ) ) ;