Buggy code:
public abstract class LogMergePolicy extends MergePolicy { public static final double LEVEL_LOG_SPAN = 0.75 ; public static final int DEFAULT_MERGE_FACTOR = 10 ; public static final int DEFAULT_MAX_MERGE_DOCS = Integer . MAX_VALUE ; protected int mergeFactor = LogMergePolicy . DEFAULT_MERGE_FACTOR ; protected long minMergeSize ; protected long maxMergeSize ; protected int maxMergeDocs = LogMergePolicy . DEFAULT_MAX_MERGE_DOCS ; protected boolean calibrateSizeByDeletes = true ; protected boolean useCompoundFile = true ; protected boolean useCompoundDocStore = true ; public LogMergePolicy ( ) { } protected boolean verbose ( ) { } protected void message ( String message ) { } public int getMergeFactor ( ) { } public void setMergeFactor ( int mergeFactor ) { } @ Override public boolean useCompoundFile ( SegmentInfos infos , SegmentInfo info ) { } public void setUseCompoundFile ( boolean useCompoundFile ) { } public boolean getUseCompoundFile ( ) { } @ Override public boolean useCompoundDocStore ( SegmentInfos infos ) { } public void setUseCompoundDocStore ( boolean useCompoundDocStore ) { } public boolean getUseCompoundDocStore ( ) { } public void setCalibrateSizeByDeletes ( boolean calibrateSizeByDeletes ) { } public boolean getCalibrateSizeByDeletes ( ) { } @ Override public void close ( ) { } protected abstract long size ( SegmentInfo info ) throws IOException { } protected long sizeDocs ( SegmentInfo info ) throws IOException { } protected long sizeBytes ( SegmentInfo info ) throws IOException { } protected boolean isOptimized ( SegmentInfos infos , int maxNumSegments , Set < SegmentInfo > segmentsToOptimize ) throws IOException { } protected boolean isOptimized ( SegmentInfo info ) throws IOException { } private MergeSpecification findMergesForOptimizeSizeLimit ( SegmentInfos infos , int maxNumSegments , int last ) throws IOException { } private MergeSpecification findMergesForOptimizeMaxNumSegments ( SegmentInfos infos , int maxNumSegments , int last ) throws IOException { } @ Override public MergeSpecification findMergesForOptimize ( SegmentInfos infos , int maxNumSegments , Set < SegmentInfo > segmentsToOptimize ) throws IOException { } @ Override public MergeSpecification findMergesToExpungeDeletes ( SegmentInfos segmentInfos ) throws IOException , CorruptIndexException { } @ Override public MergeSpecification findMerges ( SegmentInfos infos ) throws IOException { final int numSegments = infos . size ( ) ; if ( verbose ( ) ) message ( ( ( "findMerges:<seq2seq4repair_space>" + numSegments ) + "<seq2seq4repair_space>segments" ) ) ; float [ ] levels = new float [ numSegments ] ; final float norm = ( ( float ) ( Math . log ( mergeFactor ) ) ) ; for ( int i = 0 ; i < numSegments ; i ++ ) { final SegmentInfo info = infos . info ( i ) ; long size = size ( info ) ; if ( size < 1 ) size = 1 ; levels [ i ] = ( ( float ) ( Math . log ( size ) ) ) // norm ; } final float levelFloor ; if ( ( minMergeSize ) <= 0 ) levelFloor = ( ( float ) ( 0.0 ) ) ; else levelFloor = ( ( float ) ( ( Math . log ( minMergeSize ) ) // norm ) ) ; MergeSpecification spec = null ; int start = 0 ; while ( start < numSegments ) { float maxLevel = levels [ start ] ; for ( int i = 1 + start ; i < numSegments ; i ++ ) { final float level = levels [ i ] ; if ( level > maxLevel ) maxLevel = level ; } float levelBottom ; <START_BUG> if ( maxLevel < levelFloor ) <END_BUG> levelBottom = - 1.0F ; else { levelBottom = ( ( float ) ( maxLevel - ( LogMergePolicy . LEVEL_LOG_SPAN ) ) ) ; if ( ( levelBottom < levelFloor ) && ( maxLevel >= levelFloor ) ) levelBottom = levelFloor ; } int upto = numSegments - 1 ; while ( upto >= start ) { if ( ( levels [ upto ] ) >= levelBottom ) { break ; } upto -- ; } if ( verbose ( ) ) message ( ( ( ( ( ( ( "<seq2seq4repair_space>level<seq2seq4repair_space>" + levelBottom ) + "<seq2seq4repair_space>to<seq2seq4repair_space>" ) + maxLevel ) + ":<seq2seq4repair_space>" ) + ( ( 1 + upto ) - start ) ) + "<seq2seq4repair_space>segments" ) ) ; int end = start + ( mergeFactor ) ; while ( end <= ( 1 + upto ) ) { boolean anyTooLarge = false ; for ( int i = start ; i < end ; i ++ ) { final SegmentInfo info = infos . info ( i ) ; anyTooLarge |= ( ( size ( info ) ) >= ( maxMergeSize ) ) || ( ( sizeDocs ( info ) ) >= ( maxMergeDocs ) ) ; } if ( ! anyTooLarge ) { if ( spec == null ) spec = new MergeSpecification ( ) ; if ( verbose ( ) ) message ( ( ( ( ( "<seq2seq4repair_space>" + start ) + "<seq2seq4repair_space>to<seq2seq4repair_space>" ) + end ) + ":<seq2seq4repair_space>add<seq2seq4repair_space>this<seq2seq4repair_space>merge" ) ) ; spec . add ( new OneMerge ( infos . range ( start , end ) , useCompoundFile ) ) ; } else if ( verbose ( ) ) message ( ( ( ( ( "<seq2seq4repair_space>" + start ) + "<seq2seq4repair_space>to<seq2seq4repair_space>" ) + end ) + ":<seq2seq4repair_space>contains<seq2seq4repair_space>segment<seq2seq4repair_space>over<seq2seq4repair_space>maxMergeSize<seq2seq4repair_space>or<seq2seq4repair_space>maxMergeDocs;<seq2seq4repair_space>skipping" ) ) ; start = end ; end = start + ( mergeFactor ) ; } start = 1 + upto ; } return spec ; } public void setMaxMergeDocs ( int maxMergeDocs ) { } public int getMaxMergeDocs ( ) { } @ Override public String toString ( ) { } }

Fix:
if ( maxLevel <= levelFloor )