Buggy code:
private static int defaultGenFileRetryCount = 10 ; private static int defaultGenFileRetryPauseMsec = 50 ; private static int defaultGenLookaheadCount = 10 ; public static void setDefaultGenFileRetryCount ( int count ) { } public static int getDefaultGenFileRetryCount ( ) { } public static void setDefaultGenFileRetryPauseMsec ( int msec ) { } public static int getDefaultGenFileRetryPauseMsec ( ) { } public static void setDefaultGenLookaheadCount ( int count ) { } public static int getDefaultGenLookahedCount ( ) { } public static PrintStream getInfoStream ( ) { } private static void message ( String message ) { } public abstract static class FindSegmentsFile { final Directory directory ; public FindSegmentsFile ( Directory directory ) { } public Object run ( ) throws IOException , CorruptIndexException { } public Object run ( IndexCommit commit ) throws IOException , CorruptIndexException { if ( commit != null ) { if ( ( directory ) != ( commit . getDirectory ( ) ) ) throw new IOException ( "the<seq2seq4repair_space>specified<seq2seq4repair_space>commit<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>match<seq2seq4repair_space>the<seq2seq4repair_space>specified<seq2seq4repair_space>Directory" ) ; return doBody ( commit . getSegmentsFileName ( ) ) ; } String segmentFileName = null ; long lastGen = - 1 ; long gen = 0 ; int genLookaheadCount = 0 ; IOException exc = null ; boolean retry = false ; int method = 0 ; while ( true ) { if ( 0 == method ) { String [ ] files = null ; long genA = - 1 ; files = directory . listAll ( ) ; if ( files != null ) genA = SegmentInfos . getCurrentSegmentGeneration ( files ) ; if ( ( SegmentInfos . infoStream ) != null ) { SegmentInfos . message ( ( "directory<seq2seq4repair_space>listing<seq2seq4repair_space>genA=" + genA ) ) ; } long genB = - 1 ; for ( int i = 0 ; i < ( SegmentInfos . defaultGenFileRetryCount ) ; i ++ ) { IndexInput genInput = null ; try { genInput = directory . openInput ( SEGMENTS_GEN ) ; } catch ( FileNotFoundException e ) { if ( ( SegmentInfos . infoStream ) != null ) { SegmentInfos . message ( ( "segments.gen<seq2seq4repair_space>open:<seq2seq4repair_space>FileNotFoundException<seq2seq4repair_space>" + e ) ) ; } break ; } catch ( IOException e ) { if ( ( SegmentInfos . infoStream ) != null ) { SegmentInfos . message ( ( "segments.gen<seq2seq4repair_space>open:<seq2seq4repair_space>IOException<seq2seq4repair_space>" + e ) ) ; } } if ( genInput != null ) { try { int version = genInput . readInt ( ) ; if ( version == ( SegmentInfos . FORMAT_LOCKLESS ) ) { long gen0 = genInput . readLong ( ) ; long gen1 = genInput . readLong ( ) ; if ( ( SegmentInfos . infoStream ) != null ) { SegmentInfos . message ( ( ( ( "fallback<seq2seq4repair_space>check:<seq2seq4repair_space>" + gen0 ) + ";<seq2seq4repair_space>" ) + gen1 ) ) ; } if ( gen0 == gen1 ) { genB = gen0 ; break ; } } } catch ( IOException err2 ) { } finally { genInput . close ( ) ; } } try { Thread . sleep ( SegmentInfos . defaultGenFileRetryPauseMsec ) ; } catch ( InterruptedException ie ) { throw new ThreadInterruptedException ( ie ) ; } } if ( ( SegmentInfos . infoStream ) != null ) { SegmentInfos . message ( ( ( ( IndexFileNames . SEGMENTS_GEN ) + "<seq2seq4repair_space>check:<seq2seq4repair_space>genB=" ) + genB ) ) ; } if ( genA > genB ) gen = genA ; else gen = genB ; if ( gen == ( - 1 ) ) { <START_BUG> throw new IndexNotFoundException ( ( ( ( "no<seq2seq4repair_space>segments*<seq2seq4repair_space>file<seq2seq4repair_space>found<seq2seq4repair_space>in<seq2seq4repair_space>" + ( directory ) ) + ":<seq2seq4repair_space>files:<seq2seq4repair_space>" ) + ( Arrays . toString ( files ) ) ) ) ; <END_BUG> } } if ( ( 1 == method ) || ( ( ( 0 == method ) && ( lastGen == gen ) ) && retry ) ) { method = 1 ; if ( genLookaheadCount < ( SegmentInfos . defaultGenLookaheadCount ) ) { gen ++ ; genLookaheadCount ++ ; if ( ( SegmentInfos . infoStream ) != null ) { SegmentInfos . message ( ( "look<seq2seq4repair_space>ahead<seq2seq4repair_space>increment<seq2seq4repair_space>gen<seq2seq4repair_space>to<seq2seq4repair_space>" + gen ) ) ; } } } if ( lastGen == gen ) { if ( retry ) { throw exc ; } else { retry = true ; } } else if ( 0 == method ) { retry = false ; } lastGen = gen ; segmentFileName = IndexFileNames . fileNameFromGeneration ( SEGMENTS , "" , gen ) ; try { Object v = doBody ( segmentFileName ) ; if ( ( exc != null ) && ( ( SegmentInfos . infoStream ) != null ) ) { SegmentInfos . message ( ( "success<seq2seq4repair_space>on<seq2seq4repair_space>" + segmentFileName ) ) ; } return v ; } catch ( IOException err ) { if ( exc == null ) { exc = err ; } if ( ( SegmentInfos . infoStream ) != null ) { SegmentInfos . message ( ( ( ( ( ( ( ( "primary<seq2seq4repair_space>Exception<seq2seq4repair_space>on<seq2seq4repair_space>'" + segmentFileName ) + "':<seq2seq4repair_space>" ) + err ) + "';<seq2seq4repair_space>will<seq2seq4repair_space>retry:<seq2seq4repair_space>retry=" ) + retry ) + ";<seq2seq4repair_space>gen<seq2seq4repair_space>=<seq2seq4repair_space>" ) + gen ) ) ; } if ( ( ! retry ) && ( gen > 1 ) ) { String prevSegmentFileName = IndexFileNames . fileNameFromGeneration ( SEGMENTS , "" , ( gen - 1 ) ) ; final boolean prevExists ; prevExists = directory . fileExists ( prevSegmentFileName ) ; if ( prevExists ) { if ( ( SegmentInfos . infoStream ) != null ) { SegmentInfos . message ( ( ( "fallback<seq2seq4repair_space>to<seq2seq4repair_space>prior<seq2seq4repair_space>segment<seq2seq4repair_space>file<seq2seq4repair_space>'" + prevSegmentFileName ) + "'" ) ) ; } try { Object v = doBody ( prevSegmentFileName ) ; if ( ( SegmentInfos . infoStream ) != null ) { SegmentInfos . message ( ( "success<seq2seq4repair_space>on<seq2seq4repair_space>fallback<seq2seq4repair_space>" + prevSegmentFileName ) ) ; } return v ; } catch ( IOException err2 ) { if ( ( SegmentInfos . infoStream ) != null ) { SegmentInfos . message ( ( ( ( ( "secondary<seq2seq4repair_space>Exception<seq2seq4repair_space>on<seq2seq4repair_space>'" + prevSegmentFileName ) + "':<seq2seq4repair_space>" ) + err2 ) + "';<seq2seq4repair_space>will<seq2seq4repair_space>retry"

Fix:
throw new FileNotFoundException ( ( ( ( "no<seq2seq4repair_space>segments*<seq2seq4repair_space>file<seq2seq4repair_space>found<seq2seq4repair_space>in<seq2seq4repair_space>" + ( directory ) ) + ":<seq2seq4repair_space>files:<seq2seq4repair_space>" ) + ( Arrays . toString ( files ) ) ) ) ;