Buggy code:
public class TestBlockPostingsFormat3 extends LuceneTestCase { static final int MAXDOC = ( Lucene41PostingsFormat . BLOCK_SIZE ) * 20 ; public void test ( ) throws Exception { Directory dir = newDirectory ( ) ; <START_BUG> Analyzer analyzer = new Analyzer ( new Analyzer . PerFieldReuseStrategy ( ) ) { <END_BUG> @ Override protected TokenStreamComponents createComponents ( String fieldName , Reader reader ) { Tokenizer tokenizer = new MockTokenizer ( reader ) ; if ( fieldName . contains ( "payloadsFixed" ) ) { TokenFilter filter = new org . apache . lucene . analysis . MockFixedLengthPayloadFilter ( new Random ( 0 ) , tokenizer , 1 ) ; return new TokenStreamComponents ( tokenizer , filter ) ; } else if ( fieldName . contains ( "payloadsVariable" ) ) { TokenFilter filter = new org . apache . lucene . analysis . MockVariableLengthPayloadFilter ( new Random ( 0 ) , tokenizer ) ; return new TokenStreamComponents ( tokenizer , filter ) ; } else { return new TokenStreamComponents ( tokenizer ) ; } } } ; IndexWriterConfig iwc = newIndexWriterConfig ( TEST_VERSION_CURRENT , analyzer ) ; iwc . setCodec ( _TestUtil . alwaysPostingsFormat ( new Lucene41PostingsFormat ( ) ) ) ; RandomIndexWriter iw = new RandomIndexWriter ( random ( ) , dir , iwc . clone ( ) ) ; Document doc = new Document ( ) ; FieldType docsOnlyType = new FieldType ( TextField . TYPE_NOT_STORED ) ; docsOnlyType . setStoreTermVectors ( true ) ; docsOnlyType . setIndexOptions ( DOCS_ONLY ) ; FieldType docsAndFreqsType = new FieldType ( TextField . TYPE_NOT_STORED ) ; docsAndFreqsType . setStoreTermVectors ( true ) ; docsAndFreqsType . setIndexOptions ( DOCS_AND_FREQS ) ; FieldType positionsType = new FieldType ( TextField . TYPE_NOT_STORED ) ; positionsType . setStoreTermVectors ( true ) ; positionsType . setStoreTermVectorPositions ( true ) ; positionsType . setStoreTermVectorOffsets ( true ) ; positionsType . setStoreTermVectorPayloads ( true ) ; FieldType offsetsType = new FieldType ( positionsType ) ; offsetsType . setIndexOptions ( DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS ) ; Field field1 = new Field ( "field1docs" , "" , docsOnlyType ) ; Field field2 = new Field ( "field2freqs" , "" , docsAndFreqsType ) ; Field field3 = new Field ( "field3positions" , "" , positionsType ) ; Field field4 = new Field ( "field4offsets" , "" , offsetsType ) ; Field field5 = new Field ( "field5payloadsFixed" , "" , positionsType ) ; Field field6 = new Field ( "field6payloadsVariable" , "" , positionsType ) ; Field field7 = new Field ( "field7payloadsFixedOffsets" , "" , offsetsType ) ; Field field8 = new Field ( "field8payloadsVariableOffsets" , "" , offsetsType ) ; doc . add ( field1 ) ; doc . add ( field2 ) ; doc . add ( field3 ) ; doc . add ( field4 ) ; doc . add ( field5 ) ; doc . add ( field6 ) ; doc . add ( field7 ) ; doc . add ( field8 ) ; for ( int i = 0 ; i < ( TestBlockPostingsFormat3 . MAXDOC ) ; i ++ ) { String stringValue = ( ( ( ( Integer . toString ( i ) ) + "<seq2seq4repair_space>verycommon<seq2seq4repair_space>" ) + ( English . intToEnglish ( i ) . replace ( '-' , '<seq2seq4repair_space>' ) ) ) + "<seq2seq4repair_space>" ) + ( _TestUtil . randomSimpleString ( random ( ) ) ) ; field1 . setStringValue ( stringValue ) ; field2 . setStringValue ( stringValue ) ; field3 . setStringValue ( stringValue ) ; field4 . setStringValue ( stringValue ) ; field5 . setStringValue ( stringValue ) ; field6 . setStringValue ( stringValue ) ; field7 . setStringValue ( stringValue ) ; field8 . setStringValue ( stringValue ) ; iw . addDocument ( doc ) ; } iw . close ( ) ; verify ( dir ) ; _TestUtil . checkIndex ( dir ) ; iwc . setOpenMode ( APPEND ) ; IndexWriter iw2 = new IndexWriter ( dir , iwc . clone ( ) ) ; iw2 . forceMerge ( 1 ) ; iw2 . close ( ) ; verify ( dir ) ; dir . close ( ) ; } private void verify ( Directory dir ) throws Exception { } public void assertTerms ( Terms leftTerms , Terms rightTerms , boolean deep ) throws Exception { } private void assertTermsSeeking ( Terms leftTerms , Terms rightTerms ) throws Exception { } public void assertTermsStatistics ( Terms leftTerms , Terms rightTerms ) throws Exception { } public void assertTermsEnum ( TermsEnum leftTermsEnum , TermsEnum rightTermsEnum , boolean deep ) throws Exception { } public void assertTermStats ( TermsEnum leftTermsEnum , TermsEnum rightTermsEnum ) throws Exception { } public void assertDocsAndPositionsEnum ( DocsAndPositionsEnum leftDocs , DocsAndPositionsEnum rightDocs ) throws Exception { } public void assertDocsEnum ( DocsEnum leftDocs , DocsEnum rightDocs ) throws Exception { } public void assertDocsSkipping ( int docFreq , DocsEnum leftDocs , DocsEnum rightDocs ) throws Exception { } public void assertPositionsSkipping ( int docFreq , DocsAndPositionsEnum leftDocs , DocsAndPositionsEnum rightDocs ) throws Exception { } private static class RandomBits implements Bits { FixedBitSet bits ; RandomBits ( int maxDoc , double pctLive , Random random ) { } @ Override public boolean get ( int index ) { } @ Override public int length ( ) { } } }

Fix:
Analyzer analyzer = new Analyzer ( Analyzer . PER_FIELD_REUSE_STRATEGY ) {