Buggy code:
public class PulsingPostingsReaderImpl extends PostingsReaderBase { final PostingsReaderBase wrappedPostingsReader ; int maxPulsingDocFreq ; public PulsingPostingsReaderImpl ( PostingsReaderBase wrappedPostingsReader ) throws IOException { } @ Override public void init ( IndexInput termsIn ) throws IOException { } private static class PulsingTermState extends TermState { Document [ ] docs ; private TermState wrappedTermState ; private boolean pendingIndexTerm ; public Object clone ( ) { } public void copy ( TermState _other ) { } } @ Override public TermState newTermState ( ) throws IOException { } @ Override public void readTerm ( IndexInput termsIn , FieldInfo fieldInfo , TermState _termState , boolean isIndexTerm ) throws IOException { } @ Override public DocsEnum docs ( FieldInfo field , TermState _termState , Bits skipDocs , DocsEnum reuse ) throws IOException { } @ Override public BulkPostingsEnum bulkPostings ( FieldInfo field , TermState _termState , BulkPostingsEnum reuse , boolean doFreqs , boolean doPositions ) throws IOException { } @ Override public DocsAndPositionsEnum docsAndPositions ( FieldInfo field , TermState _termState , Bits skipDocs , DocsAndPositionsEnum reuse ) throws IOException { } static class PulsingDocsEnum extends DocsEnum { private int nextRead ; private Bits skipDocs ; private Document doc ; private PulsingPostingsReaderImpl . PulsingTermState state ; PulsingPostingsReaderImpl . PulsingDocsEnum reset ( Bits skipDocs , PulsingPostingsReaderImpl . PulsingTermState termState ) { } @ Override public int nextDoc ( ) { } @ Override public int freq ( ) { } @ Override public int docID ( ) { } @ Override public int advance ( int target ) throws IOException { } } static class PulsingBulkPostingsEnum extends BulkPostingsEnum { private Document doc ; private PulsingPostingsReaderImpl . PulsingTermState state ; int numDocs ; final int [ ] docDeltas ; final int [ ] freqs ; int [ ] positionDeltas ; int numPositions ; private boolean doFreqs ; private boolean doPositions ; public PulsingBulkPostingsEnum ( int maxFreq ) { } PulsingPostingsReaderImpl . PulsingBulkPostingsEnum reset ( PulsingPostingsReaderImpl . PulsingTermState termState , boolean doFreqs , boolean doPositions ) { numDocs = termState . docFreq ; this . doFreqs = doFreqs ; this . doPositions = doPositions ; assert ( numDocs ) <= ( docDeltas . length ) ; int lastDocID = 0 ; numPositions = 0 ; for ( int i = 0 ; i < ( numDocs ) ; i ++ ) { final int docID = termState . docs [ i ] . docID ; docDeltas [ i ] = docID - lastDocID ; if ( doFreqs ) { freqs [ i ] = termState . docs [ i ] . numPositions ; assert ( freqs [ i ] ) > 0 ; if ( doPositions ) { final Position [ ] positions = termState . docs [ i ] . positions ; int lastPos = 0 ; for ( int posIndex = 0 ; posIndex < ( freqs [ i ] ) ; posIndex ++ ) { if ( ( positionDeltas . length ) == ( numPositions ) ) { positionDeltas = ArrayUtil . grow ( positionDeltas , ( 1 + ( numPositions ) ) ) ; } <START_BUG> final int pos = positions [ i ] . pos ; <END_BUG> positionDeltas [ ( ( numPositions ) ++ ) ] = pos - lastPos ; lastPos = pos ; } } } lastDocID = docID ; } return this ; } private final BlockReader docDeltasReader = new BulkPostingsEnum . BlockReader ( ) { @ Override public int [ ] getBuffer ( ) { } @ Override public int fill ( ) { } @ Override public int offset ( ) { } @ Override public void setOffset ( int offset ) { } @ Override public int end ( ) { } } ; @ Override public BlockReader getDocDeltasReader ( ) { } private final BlockReader freqsReader = new BulkPostingsEnum . BlockReader ( ) { @ Override public int [ ] getBuffer ( ) { } @ Override public int fill ( ) { } @ Override public int offset ( ) { } @ Override public void setOffset ( int offset ) { } @ Override public int end ( ) { } } ; @ Override public BlockReader getFreqsReader ( ) { } private final BlockReader positionDeltasReader = new BulkPostingsEnum . BlockReader ( ) { @ Override public int [ ] getBuffer ( ) { } @ Override public int fill ( ) { } @ Override public int offset ( ) { } @ Override public void setOffset ( int offset ) { } @ Override public int end ( ) { } } ; @ Override public BlockReader getPositionDeltasReader ( ) { } @ Override public JumpResult jump ( int target , int curCount ) throws IOException { } } static class PulsingDocsAndPositionsEnum extends DocsAndPositionsEnum { private int nextRead ; private int nextPosRead ; private Bits skipDocs ; private Document doc ; private Position pos ; private PulsingPostingsReaderImpl . PulsingTermState state ; private boolean payloadRetrieved ; public void close ( ) { } PulsingPostingsReaderImpl . PulsingDocsAndPositionsEnum reset ( Bits skipDocs , PulsingPostingsReaderImpl . PulsingTermState termState ) { } @ Override public int nextDoc ( ) { } @ Override public int freq ( ) { } @ Override public int docID ( ) { } @ Override public int advance ( int target ) throws IOException { } @ Override public int nextPosition ( ) { } @ Override public boolean hasPayload ( ) { } @ Override public BytesRef getPayload ( ) { } } @ Override public void close ( ) throws IOException { } }

Fix:
final int pos = positions [ posIndex ] . pos ;