Buggy code:
public class TestTermInfosReaderIndex extends LuceneTestCase { private static int NUMBER_OF_DOCUMENTS ; private static int NUMBER_OF_FIELDS ; private static TermInfosReaderIndex index ; private static Directory directory ; private static SegmentTermEnum termEnum ; private static int indexDivisor ; private static int termIndexInterval ; private static IndexReader reader ; private static List < Term > sampleTerms ; @ BeforeClass public static void beforeClass ( ) throws Exception { <START_BUG> LuceneTestCase . PREFLEX_IMPERSONATION_IS_ACTIVE = true ; <END_BUG> IndexWriterConfig config = newIndexWriterConfig ( TEST_VERSION_CURRENT , new org . apache . lucene . analysis . MockAnalyzer ( random ( ) , MockTokenizer . KEYWORD , false ) ) . setUseCompoundFile ( false ) ; TestTermInfosReaderIndex . termIndexInterval = config . getTermIndexInterval ( ) ; TestTermInfosReaderIndex . indexDivisor = _TestUtil . nextInt ( random ( ) , 1 , 10 ) ; TestTermInfosReaderIndex . NUMBER_OF_DOCUMENTS = atLeast ( 100 ) ; TestTermInfosReaderIndex . NUMBER_OF_FIELDS = atLeast ( Math . max ( 10 , ( ( ( 3 * ( TestTermInfosReaderIndex . termIndexInterval ) ) * ( TestTermInfosReaderIndex . indexDivisor ) ) // ( TestTermInfosReaderIndex . NUMBER_OF_DOCUMENTS ) ) ) ) ; TestTermInfosReaderIndex . directory = newDirectory ( ) ; config . setCodec ( new PreFlexRWCodec ( ) ) ; LogMergePolicy mp = newLogMergePolicy ( ) ; mp . setNoCFSRatio ( 0.0 ) ; config . setMergePolicy ( mp ) ; TestTermInfosReaderIndex . populate ( TestTermInfosReaderIndex . directory , config ) ; DirectoryReader r0 = IndexReader . open ( TestTermInfosReaderIndex . directory ) ; SegmentReader r = LuceneTestCase . getOnlySegmentReader ( r0 ) ; String segment = r . getSegmentName ( ) ; r . close ( ) ; FieldInfosReader infosReader = new PreFlexRWCodec ( ) . fieldInfosFormat ( ) . getFieldInfosReader ( ) ; FieldInfos fieldInfos = infosReader . read ( TestTermInfosReaderIndex . directory , segment , "" , READONCE ) ; String segmentFileName = IndexFileNames . segmentFileName ( segment , "" , TERMS_INDEX_EXTENSION ) ; long tiiFileLength = TestTermInfosReaderIndex . directory . fileLength ( segmentFileName ) ; IndexInput input = TestTermInfosReaderIndex . directory . openInput ( segmentFileName , newIOContext ( random ( ) ) ) ; TestTermInfosReaderIndex . termEnum = new SegmentTermEnum ( TestTermInfosReaderIndex . directory . openInput ( IndexFileNames . segmentFileName ( segment , "" , TERMS_EXTENSION ) , newIOContext ( random ( ) ) ) , fieldInfos , false ) ; int totalIndexInterval = ( TestTermInfosReaderIndex . termEnum . indexInterval ) * ( TestTermInfosReaderIndex . indexDivisor ) ; SegmentTermEnum indexEnum = new SegmentTermEnum ( input , fieldInfos , true ) ; TestTermInfosReaderIndex . index = new TermInfosReaderIndex ( indexEnum , TestTermInfosReaderIndex . indexDivisor , tiiFileLength , totalIndexInterval ) ; indexEnum . close ( ) ; input . close ( ) ; TestTermInfosReaderIndex . reader = IndexReader . open ( TestTermInfosReaderIndex . directory ) ; TestTermInfosReaderIndex . sampleTerms = TestTermInfosReaderIndex . sample ( random ( ) , TestTermInfosReaderIndex . reader , 1000 ) ; } @ AfterClass public static void afterClass ( ) throws Exception { } public void testSeekEnum ( ) throws IOException , CorruptIndexException { } public void testCompareTo ( ) throws IOException { } public void testRandomSearchPerformance ( ) throws IOException , CorruptIndexException { } private static List < Term > sample ( Random random , IndexReader reader , int size ) throws IOException { } private Term findTermThatWouldBeAtIndex ( SegmentTermEnum termEnum , int index ) throws IOException { } private static void populate ( Directory directory , IndexWriterConfig config ) throws IOException , CorruptIndexException , LockObtainFailedException { } private static String getText ( ) { } }

Fix:
LuceneTestCase . OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true ;