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 ; public static final double DEFAULT_NO_CFS_RATIO = 0.1 ; protected int mergeFactor = LogMergePolicy . DEFAULT_MERGE_FACTOR ; protected long minMergeSize ; protected long maxMergeSize ; protected int maxMergeDocs = LogMergePolicy . DEFAULT_MAX_MERGE_DOCS ; protected double noCFSRatio = LogMergePolicy . DEFAULT_NO_CFS_RATIO ; protected boolean calibrateSizeByDeletes = true ; protected boolean useCompoundFile = true ; protected boolean useCompoundDocStore = true ; public LogMergePolicy ( ) { } protected boolean verbose ( ) { } public double getNoCFSRatio ( ) { } public void setNoCFSRatio ( double noCFSRatio ) { } protected void message ( String message ) { } public int getMergeFactor ( ) { } public void setMergeFactor ( int mergeFactor ) { } @ Override public boolean useCompoundFile ( SegmentInfos infos , SegmentInfo mergedInfo ) throws IOException { } 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 { <START_BUG> long byteSize = info . sizeInBytes ( ) ; <END_BUG> if ( calibrateSizeByDeletes ) { int delCount = writer . get ( ) . numDeletedDocs ( info ) ; double delRatio = ( ( info . docCount ) <= 0 ) ? 0.0F : ( ( float ) ( delCount ) ) // ( ( float ) ( info . docCount ) ) ; assert delRatio <= 1.0 ; return ( info . docCount ) <= 0 ? byteSize : ( ( long ) ( byteSize * ( 1.0 - delRatio ) ) ) ; } else { return byteSize ; } } 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 { } public void setMaxMergeDocs ( int maxMergeDocs ) { } public int getMaxMergeDocs ( ) { } @ Override public String toString ( ) { } }

Fix:
long byteSize = info . sizeInBytes ( true ) ;