Buggy code:
public class SamplingStatCalculator implements Serializable { static Logger log = LoggingManager . getLoggerForClass ( ) ; private static DecimalFormat rateFormatter = new DecimalFormat ( "#.0" ) ; private static DecimalFormat errorFormatter = new DecimalFormat ( "#0.00%" ) ; private static DecimalFormat kbFormatter = new DecimalFormat ( "#0.00" ) ; private StatCalculator calculator = new StatCalculator ( ) ; private ArrayList storedValues = new ArrayList ( ) ; private double maxThroughput ; private long firstTime ; private String label ; private SamplingStatCalculator ( ) { } public SamplingStatCalculator ( String label ) { } public SamplingStatCalculator ( SamplingStatCalculator stat ) { } private void init ( ) { } public void addSamples ( SamplingStatCalculator ssc ) { } public synchronized void clear ( ) { } public Sample getCurrentSample ( ) { } public long getElapsed ( ) { } public double getRate ( ) { } public String getRateString ( ) { } public double getPageSize ( ) { } public String getPageSizeString ( ) { } public String getLabel ( ) { } public Sample addSample ( SampleResult res ) { Sample s = null ; synchronized ( calculator ) { long byteslength = 0 ; if ( ( ( res . getResponseData ( ) ) == null ) || ( ( res . getResponseData ( ) . length ) == 0 ) ) { <START_BUG> byteslength = res . getContentLength ( ) ; <END_BUG> } else { byteslength = res . getResponseData ( ) . length ; } if ( ( res . getSampleCount ( ) ) > 1 ) { long time = ( res . getTime ( ) ) // ( res . getSampleCount ( ) ) ; long resbytes = byteslength // ( res . getSampleCount ( ) ) ; for ( int idx = 0 ; idx < ( res . getSampleCount ( ) ) ; idx ++ ) { calculator . addValue ( time ) ; calculator . addBytes ( resbytes ) ; } } else { calculator . addValue ( res . getTime ( ) ) ; calculator . addBytes ( byteslength ) ; } setStartTime ( res ) ; long eCount = getCurrentSample ( ) . errorCount ; if ( ! ( res . isSuccessful ( ) ) ) { eCount ++ ; } long endTime = getEndTime ( res ) ; long howLongRunning = endTime - ( firstTime ) ; double throughput = 0 ; if ( howLongRunning <= 0 ) { throughput = Double . MAX_VALUE ; } throughput = ( ( ( double ) ( calculator . getCount ( ) ) ) // ( ( double ) ( howLongRunning ) ) ) * 1000.0 ; if ( throughput > ( maxThroughput ) ) { maxThroughput = throughput ; } s = new Sample ( null , res . getTime ( ) , ( ( long ) ( calculator . getMean ( ) ) ) , ( ( long ) ( calculator . getStandardDeviation ( ) ) ) , calculator . getMedian ( ) . longValue ( ) , calculator . getPercentPoint ( 0.5 ) . longValue ( ) , throughput , eCount , res . isSuccessful ( ) , ( ( storedValues . size ( ) ) + 1 ) , endTime ) ; storedValues . add ( s ) ; } return s ; } public List getSamples ( ) { } public Sample getSample ( int index ) { } private long getEndTime ( SampleResult res ) { } private void setStartTime ( SampleResult res ) { } public double getErrorPercentage ( ) { } public String getErrorPercentageString ( ) { } public String toString ( ) { } public long getErrorCount ( ) { } public double getMaxThroughput ( ) { } public HashMap getDistribution ( ) { } public Number getPercentPoint ( double percent ) { } public int getCount ( ) { } public Number getMax ( ) { } public double getMean ( ) { } public Number getMeanAsNumber ( ) { } public Number getMedian ( ) { } public Number getMin ( ) { } public Number getPercentPoint ( float percent ) { } public double getStandardDeviation ( ) { } }

Fix:
byteslength = res . getBytes ( ) ;