Buggy code:
public abstract class ReadTask extends PerfTask { private final QueryMaker queryMaker ; public ReadTask ( PerfRunData runData ) { } @ Override public int doLogic ( ) throws Exception { int res = 0 ; IndexSearcher searcher = getRunData ( ) . getIndexSearcher ( ) ; IndexReader reader ; final boolean closeSearcher ; if ( searcher == null ) { Directory dir = getRunData ( ) . getDirectory ( ) ; reader = IndexReader . open ( dir , true ) ; searcher = new IndexSearcher ( reader ) ; closeSearcher = true ; } else { reader = searcher . getIndexReader ( ) ; closeSearcher = false ; } if ( withWarm ( ) ) { Document doc = null ; for ( int m = 0 ; m < ( reader . maxDoc ( ) ) ; m ++ ) { if ( ! ( reader . isDeleted ( m ) ) ) { doc = reader . document ( m ) ; res += ( doc == null ) ? 0 : 1 ; } } } if ( withSearch ( ) ) { res ++ ; Query q = queryMaker . makeQuery ( ) ; Sort sort = getSort ( ) ; TopDocs hits = null ; final int numHits = numHits ( ) ; if ( numHits > 0 ) { if ( ( withCollector ( ) ) == false ) { if ( sort != null ) { <START_BUG> Weight w = q . weight ( searcher ) ; <END_BUG> TopFieldCollector collector = TopFieldCollector . create ( sort , numHits , true , withScore ( ) , withMaxScore ( ) , ( ! ( w . scoresDocsOutOfOrder ( ) ) ) ) ; searcher . search ( w , null , collector ) ; hits = collector . topDocs ( ) ; } else { hits = searcher . search ( q , numHits ) ; } } else { Collector collector = createCollector ( ) ; searcher . search ( q , null , collector ) ; } final String printHitsField = getRunData ( ) . getConfig ( ) . get ( "print.hits.field" , null ) ; if ( ( ( hits != null ) && ( printHitsField != null ) ) && ( ( printHitsField . length ( ) ) > 0 ) ) { if ( q instanceof MultiTermQuery ) { System . out . println ( ( "MultiTermQuery<seq2seq4repair_space>term<seq2seq4repair_space>count<seq2seq4repair_space>=<seq2seq4repair_space>" + ( ( ( MultiTermQuery ) ( q ) ) . getTotalNumberOfTerms ( ) ) ) ) ; } System . out . println ( ( "totalHits<seq2seq4repair_space>=<seq2seq4repair_space>" + ( hits . totalHits ) ) ) ; System . out . println ( ( "maxDoc()<seq2seq4repair_space>=<seq2seq4repair_space>" + ( reader . maxDoc ( ) ) ) ) ; System . out . println ( ( "numDocs()<seq2seq4repair_space>=<seq2seq4repair_space>" + ( reader . numDocs ( ) ) ) ) ; for ( int i = 0 ; i < ( hits . scoreDocs . length ) ; i ++ ) { final int docID = hits . scoreDocs [ i ] . doc ; final Document doc = reader . document ( docID ) ; System . out . println ( ( ( ( ( ( ( ( ( ( "<seq2seq4repair_space>" + i ) + ":<seq2seq4repair_space>doc=" ) + docID ) + "<seq2seq4repair_space>score=" ) + ( hits . scoreDocs [ i ] . score ) ) + "<seq2seq4repair_space>" ) + printHitsField ) + "<seq2seq4repair_space>=" ) + ( doc . get ( printHitsField ) ) ) ) ; } } if ( withTraverse ( ) ) { final ScoreDoc [ ] scoreDocs = hits . scoreDocs ; int traversalSize = Math . min ( scoreDocs . length , traversalSize ( ) ) ; if ( traversalSize > 0 ) { boolean retrieve = withRetrieve ( ) ; int numHighlight = Math . min ( numToHighlight ( ) , scoreDocs . length ) ; Analyzer analyzer = getRunData ( ) . getAnalyzer ( ) ; BenchmarkHighlighter highlighter = null ; if ( numHighlight > 0 ) { highlighter = getBenchmarkHighlighter ( q ) ; } for ( int m = 0 ; m < traversalSize ; m ++ ) { int id = scoreDocs [ m ] . doc ; res ++ ; if ( retrieve ) { Document document = retrieveDoc ( reader , id ) ; res += ( document != null ) ? 1 : 0 ; if ( ( numHighlight > 0 ) && ( m < numHighlight ) ) { Collection < String > fieldsToHighlight = getFieldsToHighlight ( document ) ; for ( final String field : fieldsToHighlight ) { String text = document . get ( field ) ; res += highlighter . doHighlight ( reader , id , field , document , analyzer , text ) ; } } } } } } } } if ( closeSearcher ) { searcher . close ( ) ; reader . close ( ) ; } else { reader . decRef ( ) ; } return res ; } protected Collector createCollector ( ) throws Exception { } protected Document retrieveDoc ( IndexReader ir , int id ) throws IOException { } public abstract QueryMaker getQueryMaker ( ) { } public abstract boolean withSearch ( ) { } public boolean withCollector ( ) { } public abstract boolean withWarm ( ) { } public abstract boolean withTraverse ( ) { } public boolean withScore ( ) { } public boolean withMaxScore ( ) { } public int traversalSize ( ) { } static final int DEFAULT_SEARCH_NUM_HITS = 10 ; private int numHits ; @ Override public void setup ( ) throws Exception { } public int numHits ( ) { } public abstract boolean withRetrieve ( ) { } public int numToHighlight ( ) { } protected BenchmarkHighlighter getBenchmarkHighlighter ( Query q ) { } protected Sort getSort ( ) { } protected Collection < String > getFieldsToHighlight ( Document document ) { } }

Fix:
Weight w = searcher . createNormalizedWeight ( q ) ;