Buggy code:
protected static void assertSaneFieldCaches ( final String msg ) { } public static int atLeast ( Random random , int i ) { } public static int atLeast ( int i ) { } public static boolean rarely ( Random random ) { } public static boolean rarely ( ) { } public static boolean usually ( Random random ) { } public static boolean usually ( ) { } public static void assumeTrue ( String msg , boolean condition ) { } public static void assumeFalse ( String msg , boolean condition ) { } public static void assumeNoException ( String msg , Exception e ) { } public static < T > Set < T > asSet ( T ... args ) { } public static void dumpIterator ( String label , Iterator < ? > iter , PrintStream stream ) { } public static void dumpArray ( String label , Object [ ] objs , PrintStream stream ) { } public static IndexWriterConfig newIndexWriterConfig ( Version v , Analyzer a ) { } public static IndexWriterConfig newIndexWriterConfig ( Random r , Version v , Analyzer a ) { } public static LogMergePolicy newLogMergePolicy ( ) { } public static TieredMergePolicy newTieredMergePolicy ( ) { } public static AlcoholicMergePolicy newAlcoholicMergePolicy ( ) { } public static AlcoholicMergePolicy newAlcoholicMergePolicy ( Random r , TimeZone tz ) { } public static LogMergePolicy newLogMergePolicy ( Random r ) { } public static TieredMergePolicy newTieredMergePolicy ( Random r ) { } public static LogMergePolicy newLogMergePolicy ( boolean useCFS ) { } public static LogMergePolicy newLogMergePolicy ( boolean useCFS , int mergeFactor ) { } public static LogMergePolicy newLogMergePolicy ( int mergeFactor ) { } public static MockDirectoryWrapper newDirectory ( ) { } public static MockDirectoryWrapper newDirectory ( Random r ) { } public static MockDirectoryWrapper newDirectory ( Directory d ) throws IOException { } public static MockDirectoryWrapper newFSDirectory ( File f ) { } public static MockDirectoryWrapper newFSDirectory ( File f , LockFactory lf ) { } public static MockDirectoryWrapper newDirectory ( Random r , Directory d ) throws IOException { } private static Directory maybeNRTWrap ( Random random , Directory directory ) { } public static Field newStringField ( String name , String value , Store stored ) { } public static Field newTextField ( String name , String value , Store stored ) { } public static Field newStringField ( Random random , String name , String value , Store stored ) { } public static Field newTextField ( Random random , String name , String value , Store stored ) { } public static Field newField ( String name , String value , FieldType type ) { } public static Field newField ( Random random , String name , String value , FieldType type ) { } public static Locale randomLocale ( Random random ) { } public static TimeZone randomTimeZone ( Random random ) { } public static Locale localeForName ( String localeName ) { } private static Directory newFSDirectoryImpl ( Class < ? extends FSDirectory > clazz , File file ) throws IOException { } static Directory newDirectoryImpl ( Random random , String clazzName ) { } public static IndexReader maybeWrapReader ( IndexReader r ) throws IOException { Random random = LuceneTestCase . random ( ) ; if ( LuceneTestCase . rarely ( ) ) { final boolean wasOriginallyAtomic = r instanceof AtomicReader ; for ( int i = 0 , c = ( random . nextInt ( 6 ) ) + 1 ; i < c ; i ++ ) { switch ( random . nextInt ( 5 ) ) { case 0 : r = SlowCompositeReaderWrapper . wrap ( r ) ; break ; case 1 : r = ( r instanceof AtomicReader ) ? new ParallelAtomicReader ( ( ( AtomicReader ) ( r ) ) ) : new ParallelCompositeReader ( ( ( CompositeReader ) ( r ) ) ) ; break ; case 2 : r = new FCInvisibleMultiReader ( r ) ; break ; case 3 : final AtomicReader ar = SlowCompositeReaderWrapper . wrap ( r ) ; final List < String > allFields = new ArrayList < String > ( ) ; for ( FieldInfo fi : ar . getFieldInfos ( ) ) { allFields . add ( fi . name ) ; } Collections . shuffle ( allFields , random ) ; final int end = ( allFields . isEmpty ( ) ) ? 0 : random . nextInt ( allFields . size ( ) ) ; final Set < String > fields = new HashSet < String > ( allFields . subList ( 0 , end ) ) ; r = new ParallelAtomicReader ( new FieldFilterAtomicReader ( ar , fields , false ) , new FieldFilterAtomicReader ( ar , fields , true ) ) ; break ; case 4 : if ( r instanceof AtomicReader ) { r = new FCInvisibleMultiReader ( new AssertingAtomicReader ( ( ( AtomicReader ) ( r ) ) ) ) ; } else if ( r instanceof DirectoryReader ) { <START_BUG> r = new FCInvisibleMultiReader ( new AssertingDirectoryReader ( ( ( DirectoryReader ) ( r ) ) ) ) ; <END_BUG> } break ; default : fail ( "should<seq2seq4repair_space>not<seq2seq4repair_space>get<seq2seq4repair_space>here" ) ; } } if ( wasOriginallyAtomic ) { r = SlowCompositeReaderWrapper . wrap ( r ) ; } else if ( ( r instanceof CompositeReader ) && ( ! ( r instanceof FCInvisibleMultiReader ) ) ) { r = new FCInvisibleMultiReader ( r ) ; } if ( LuceneTestCase . VERBOSE ) { System . out . println ( ( "maybeWrapReader<seq2seq4repair_space>wrapped:<seq2seq4repair_space>" + r ) ) ; } } return r ; } public static IOContext newIOContext ( Random random ) { } public static IndexSearcher newSearcher ( IndexReader r ) throws IOException { } public static IndexSearcher newSearcher ( IndexReader r , boolean maybeWrap ) throws IOException { } protected File getDataFile ( String name ) throws IOException { } }

Fix:
r = new FCInvisibleMultiReader ( ( ( DirectoryReader ) ( r ) ) ) ;