Buggy code:
public class StandardPostingsReader extends PostingsReaderBase { private final IndexInput freqIn ; private final IndexInput proxIn ; int skipInterval ; int maxSkipLevels ; int skipMinimum ; public StandardPostingsReader ( Directory dir , SegmentInfo segmentInfo , int readBufferSize , int codecId ) throws IOException { } public static void files ( Directory dir , SegmentInfo segmentInfo , int id , Collection < String > files ) throws IOException { } @ Override public void init ( IndexInput termsIn ) throws IOException { } private static final class StandardTermState extends BlockTermState { long freqOffset ; long proxOffset ; int skipOffset ; ByteArrayDataInput bytesReader ; byte [ ] bytes ; @ Override public Object clone ( ) { } @ Override public void copyFrom ( TermState _other ) { } @ Override public String toString ( ) { } } @ Override public BlockTermState newTermState ( ) { } @ Override public void close ( ) throws IOException { } @ Override public void readTermsBlock ( IndexInput termsIn , FieldInfo fieldInfo , BlockTermState _termState ) throws IOException { final StandardPostingsReader . StandardTermState termState = ( ( StandardPostingsReader . StandardTermState ) ( _termState ) ) ; final int len = termsIn . readVInt ( ) ; if ( ( termState . bytes ) == null ) { termState . bytes = new byte [ ArrayUtil . oversize ( len , 1 ) ] ; <START_BUG> termState . bytesReader = new ByteArrayDataInput ( null ) ; <END_BUG> } else if ( ( termState . bytes . length ) < len ) { termState . bytes = new byte [ ArrayUtil . oversize ( len , 1 ) ] ; } termsIn . readBytes ( termState . bytes , 0 , len ) ; termState . bytesReader . reset ( termState . bytes , 0 , len ) ; } @ Override public void nextTerm ( FieldInfo fieldInfo , BlockTermState _termState ) throws IOException { } @ Override public DocsEnum docs ( FieldInfo fieldInfo , BlockTermState termState , Bits skipDocs , DocsEnum reuse ) throws IOException { } @ Override public DocsAndPositionsEnum docsAndPositions ( FieldInfo fieldInfo , BlockTermState termState , Bits skipDocs , DocsAndPositionsEnum reuse ) throws IOException { } private class SegmentDocsEnum extends DocsEnum { final IndexInput freqIn ; final IndexInput startFreqIn ; boolean omitTF ; boolean storePayloads ; int limit ; int ord ; int doc ; int freq ; Bits skipDocs ; long freqOffset ; int skipOffset ; boolean skipped ; DefaultSkipListReader skipper ; public SegmentDocsEnum ( IndexInput freqIn ) throws IOException { } public StandardPostingsReader . SegmentDocsEnum reset ( FieldInfo fieldInfo , StandardPostingsReader . StandardTermState termState , Bits skipDocs ) throws IOException { } @ Override public int nextDoc ( ) throws IOException { } @ Override public int read ( ) throws IOException { } @ Override public int docID ( ) { } @ Override public int freq ( ) { } @ Override public int advance ( int target ) throws IOException { } } private class SegmentDocsAndPositionsEnum extends DocsAndPositionsEnum { final IndexInput startFreqIn ; private final IndexInput freqIn ; private final IndexInput proxIn ; int limit ; int ord ; int doc ; int freq ; int position ; Bits skipDocs ; long freqOffset ; int skipOffset ; long proxOffset ; int posPendingCount ; boolean skipped ; DefaultSkipListReader skipper ; private long lazyProxPointer ; public SegmentDocsAndPositionsEnum ( IndexInput freqIn , IndexInput proxIn ) throws IOException { } public StandardPostingsReader . SegmentDocsAndPositionsEnum reset ( FieldInfo fieldInfo , StandardPostingsReader . StandardTermState termState , Bits skipDocs ) throws IOException { } @ Override public int nextDoc ( ) throws IOException { } @ Override public int docID ( ) { } @ Override public int freq ( ) { } @ Override public int advance ( int target ) throws IOException { } @ Override public int nextPosition ( ) throws IOException { } @ Override public BytesRef getPayload ( ) throws IOException { } @ Override public boolean hasPayload ( ) { } } private class SegmentDocsAndPositionsAndPayloadsEnum extends DocsAndPositionsEnum { final IndexInput startFreqIn ; private final IndexInput freqIn ; private final IndexInput proxIn ; int limit ; int ord ; int doc ; int freq ; int position ; Bits skipDocs ; long freqOffset ; int skipOffset ; long proxOffset ; int posPendingCount ; int payloadLength ; boolean payloadPending ; boolean skipped ; DefaultSkipListReader skipper ; private BytesRef payload ; private long lazyProxPointer ; public SegmentDocsAndPositionsAndPayloadsEnum ( IndexInput freqIn , IndexInput proxIn ) throws IOException { } public StandardPostingsReader . SegmentDocsAndPositionsAndPayloadsEnum reset ( FieldInfo fieldInfo , StandardPostingsReader . StandardTermState termState , Bits skipDocs ) throws IOException { } @ Override public int nextDoc ( ) throws IOException { } @ Override public int docID ( ) { } @ Override public int freq ( ) { } @ Override public int advance ( int target ) throws IOException { } @ Override public int nextPosition ( ) throws IOException { } @ Override public BytesRef getPayload ( ) throws IOException { } @ Override public boolean hasPayload ( ) { } } }

Fix:
termState . bytesReader = new ByteArrayDataInput ( ) ;