Buggy code:
public class PulsingPostingsReader extends PostingsReaderBase { final PostingsReaderBase wrappedPostingsReader ; int maxPositions ; public PulsingPostingsReader ( PostingsReaderBase wrappedPostingsReader ) throws IOException { } @ Override public void init ( IndexInput termsIn ) throws IOException { } private static class PulsingTermState extends BlockTermState { private byte [ ] postings ; private int postingsSize ; private BlockTermState wrappedTermState ; ByteArrayDataInput inlinedBytesReader ; private byte [ ] inlinedBytes ; @ Override public Object clone ( ) { } @ Override public void copyFrom ( TermState _other ) { } @ Override public String toString ( ) { } } @ Override public void readTermsBlock ( IndexInput termsIn , FieldInfo fieldInfo , BlockTermState _termState ) throws IOException { } @ Override public BlockTermState newTermState ( ) throws IOException { } @ Override public void nextTerm ( FieldInfo fieldInfo , BlockTermState _termState ) throws IOException { } @ Override public DocsEnum docs ( FieldInfo field , BlockTermState _termState , Bits liveDocs , DocsEnum reuse , boolean needsFreqs ) throws IOException { } @ Override public DocsAndPositionsEnum docsAndPositions ( FieldInfo field , BlockTermState _termState , Bits liveDocs , DocsAndPositionsEnum reuse , boolean needsOffsets ) throws IOException { } private static class PulsingDocsEnum extends DocsEnum { private byte [ ] postingsBytes ; private final ByteArrayDataInput postings = new ByteArrayDataInput ( ) ; private final IndexOptions indexOptions ; private final boolean storePayloads ; private Bits liveDocs ; private int docID = - 1 ; private int accum ; private int freq ; private int payloadLength ; public PulsingDocsEnum ( FieldInfo fieldInfo ) { } public PulsingPostingsReader . PulsingDocsEnum reset ( Bits liveDocs , PulsingPostingsReader . PulsingTermState termState ) { } boolean canReuse ( FieldInfo fieldInfo ) { } @ Override public int nextDoc ( ) throws IOException { } @ Override public int freq ( ) { } @ Override public int docID ( ) { } @ Override public int advance ( int target ) throws IOException { } } private static class PulsingDocsAndPositionsEnum extends DocsAndPositionsEnum { private byte [ ] postingsBytes ; private final ByteArrayDataInput postings = new ByteArrayDataInput ( ) ; private final boolean storePayloads ; private Bits liveDocs ; private int docID = - 1 ; private int accum ; private int freq ; private int posPending ; private int position ; private int payloadLength ; private BytesRef payload ; private boolean payloadRetrieved ; public PulsingDocsAndPositionsEnum ( FieldInfo fieldInfo ) { } boolean canReuse ( FieldInfo fieldInfo ) { } public PulsingPostingsReader . PulsingDocsAndPositionsEnum reset ( Bits liveDocs , PulsingPostingsReader . PulsingTermState termState ) { } @ Override public int nextDoc ( ) throws IOException { } @ Override public int freq ( ) { } @ Override public int docID ( ) { } @ Override public int advance ( int target ) throws IOException { } @ Override public int nextPosition ( ) throws IOException { assert ( posPending ) > 0 ; ( posPending ) -- ; if ( storePayloads ) { if ( ! ( payloadRetrieved ) ) { postings . skipBytes ( payloadLength ) ; } final int code = postings . readVInt ( ) ; if ( ( code & 1 ) != 0 ) { payloadLength = postings . readVInt ( ) ; } <START_BUG> position += code > > 1 ; <END_BUG> payloadRetrieved = false ; } else { position += postings . readVInt ( ) ; } return position ; } @ Override public int startOffset ( ) { } @ Override public int endOffset ( ) { } private void skipPositions ( ) throws IOException { } @ Override public boolean hasPayload ( ) { } @ Override public BytesRef getPayload ( ) throws IOException { } } @ Override public void close ( ) throws IOException { } private DocsEnum getOther ( DocsEnum de ) { } private DocsEnum setOther ( DocsEnum de , DocsEnum other ) { } public static interface PulsingEnumAttribute extends Attribute { public Map < PulsingPostingsReader , DocsEnum > enums ( ) { } } public static final class PulsingEnumAttributeImpl extends AttributeImpl implements PulsingPostingsReader . PulsingEnumAttribute { private final Map < PulsingPostingsReader , DocsEnum > enums = new IdentityHashMap < PulsingPostingsReader , DocsEnum > ( ) ; public Map < PulsingPostingsReader , DocsEnum > enums ( ) { } @ Override public void clear ( ) { } @ Override public void copyTo ( AttributeImpl target ) { } } }

Fix:
position += code > > > 1 ;