Bug 46838 - HTTP sampler will always set the latency to 0 if response contains no data
Summary: HTTP sampler will always set the latency to 0 if response contains no data
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: HTTP (show other bugs)
Version: 2.3.2
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-11 22:07 UTC by Wang_zhifeng
Modified: 2009-04-03 02:43 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wang_zhifeng 2009-03-11 22:07:34 UTC
When I run a post operation which do a create operation on the server, the latency of the web request is always 0 no matter how big the operation is. 
I traced into the source file, and found in HTTPSamplerBase.java, if no response data, the sampleResult.latencyEnd(); will not be called. 

while ((bytesRead = in.read(readBuffer)) > -1) {
    		if (first) {
    			sampleResult.latencyEnd();
    			first = false;
    		}
    		if (asMD5 && md != null) {
    		    md.update(readBuffer, 0 , bytesRead);
    		    totalBytes += bytesRead;
    		} else {
    		    w.write(readBuffer, 0, bytesRead);
    		}
    	}

Add following code after the while loop will fix this bug.
if (first)
    sampleResult.latencyEnd();
Comment 1 Sebb 2009-04-03 02:43:24 UTC
Thanks for the report and fix.

Applied to SVN in

URL: http://svn.apache.org/viewvc?rev=761584&view=rev
Log:
Bug 46838 - if there was no data, still need to set latency in HTTPSampler

Will be in nightly builds after r761584
Comment 2 The ASF infrastructure team 2022-09-24 20:37:43 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2207