Buggy code:
public class TestPerfTasksLogic extends BenchmarkTestCase { @ Override public void setUp ( ) throws Exception { } public void testIndexAndSearchTasks ( ) throws Exception { } public void testTimedSearchTask ( ) throws Exception { } public void testBGSearchTaskThreads ( ) throws Exception { } public void testHighlighting ( ) throws Exception { } public void testHighlightingTV ( ) throws Exception { } public void testHighlightingNoTvNoStore ( ) throws Exception { } public void testExhaustContentSource ( ) throws Exception { } public void testDocMakerThreadSafety ( ) throws Exception { } public void testParallelDocMaker ( ) throws Exception { } public void testLineDocFile ( ) throws Exception { } public void testReadTokens ( ) throws Exception { final int NUM_DOCS = 20 ; String [ ] algLines1 = new String [ ] { "#<seq2seq4repair_space>-----<seq2seq4repair_space>properties<seq2seq4repair_space>" , "analyzer=org.apache.lucene.analysis.core.WhitespaceAnalyzer" , "content.source=org.apache.lucene.benchmark.byTask.feeds.LineDocSource" , "docs.file=" + ( getReuters20LinesFile ( ) ) , "#<seq2seq4repair_space>-----<seq2seq4repair_space>alg<seq2seq4repair_space>" , "{ReadTokens}:<seq2seq4repair_space>" + NUM_DOCS , "ResetSystemErase" , "CreateIndex" , "{AddDoc}:<seq2seq4repair_space>" + NUM_DOCS , "CloseIndex" } ; Benchmark benchmark = execBenchmark ( algLines1 ) ; List < TaskStats > stats = benchmark . getRunData ( ) . getPoints ( ) . taskStats ( ) ; int totalTokenCount1 = 0 ; for ( final TaskStats stat : stats ) { if ( stat . getTask ( ) . getName ( ) . equals ( "ReadTokens" ) ) { totalTokenCount1 += stat . getCount ( ) ; } } IndexReader reader = DirectoryReader . open ( benchmark . getRunData ( ) . getDirectory ( ) ) ; assertEquals ( NUM_DOCS , reader . numDocs ( ) ) ; int totalTokenCount2 = 0 ; FieldsEnum fields = MultiFields . getFields ( reader ) . iterator ( ) ; String fieldName = null ; while ( ( fieldName = fields . next ( ) ) != null ) { if ( ( ( fieldName . equals ( ID_FIELD ) ) || ( fieldName . equals ( DATE_MSEC_FIELD ) ) ) || ( fieldName . equals ( TIME_SEC_FIELD ) ) ) { continue ; } Terms terms = fields . terms ( ) ; if ( terms == null ) { continue ; } TermsEnum termsEnum = terms . iterator ( null ) ; DocsEnum docs = null ; while ( ( termsEnum . next ( ) ) != null ) { <START_BUG> docs = _TestUtil . docs ( random ( ) , termsEnum , MultiFields . getLiveDocs ( reader ) , docs , true ) ; <END_BUG> while ( ( docs . nextDoc ( ) ) != ( DocIdSetIterator . NO_MORE_DOCS ) ) { totalTokenCount2 += docs . freq ( ) ; } } } reader . close ( ) ; assertEquals ( totalTokenCount1 , totalTokenCount2 ) ; } public void testParallelExhausted ( ) throws Exception { } public void testExhaustedLooped ( ) throws Exception { } public void testCloseIndexFalse ( ) throws Exception { } public static class MyMergeScheduler extends SerialMergeScheduler { boolean called ; public MyMergeScheduler ( ) { } } public void testMergeScheduler ( ) throws Exception { } public static class MyMergePolicy extends LogDocMergePolicy { boolean called ; public MyMergePolicy ( ) { } } public void testMergePolicy ( ) throws Exception { } public void testIndexWriterSettings ( ) throws Exception { } public void testIndexingWithFacets ( ) throws Exception { } public void testForceMerge ( ) throws Exception { } public void testDisableCounting ( ) throws Exception { } private void doTestDisableCounting ( boolean disable ) throws Exception { } private String [ ] disableCountingLines ( boolean disable ) { } public void testLocale ( ) throws Exception { } private String [ ] getLocaleConfig ( String localeParam ) { } public void testCollator ( ) throws Exception { } private void assertEqualCollation ( Analyzer a1 , Analyzer a2 , String text ) throws Exception { } private String [ ] getCollatorConfig ( String localeParam , String collationParam ) { } public void testShingleAnalyzer ( ) throws Exception { } private void assertEqualShingle ( Analyzer analyzer , String text , String [ ] expected ) throws Exception { } private String [ ] getShingleConfig ( String params ) { } private String getReuters20LinesFile ( ) { } }

Fix:
docs = _TestUtil . docs ( random ( ) , termsEnum , MultiFields . getLiveDocs ( reader ) , docs , FLAG_FREQS ) ;