https://issues.apache.org/bugzilla/show_bug.cgi?id=49560
Summary: wrong "size in bytes" when following redirections
Product: JMeter
Version: 2.3.4
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: HTTP
AssignedTo: [email protected]
ReportedBy: [email protected]
Created an attachment (id=25715)
--> (https://issues.apache.org/bugzilla/attachment.cgi?id=25715)
patch for correcting the parent's "size in bytes" when following redirections
Using an HttpRequest Sampler on a url that redirects but also returns some body
message next to the 30x headers, gives wrong size in bytes.
More precise, the "parent" http sample gets a value in "size in bytes" equal to
2x[initial request] + [size of the rest subrequests]
This issue has been addressed quite some time ago
(http://www.mail-archive.com/[email protected]/msg25592.html) by
one of my colleagues (Mr. Pieter Ennes, WatchMouse.com) but it has not been
fixed yet (checked in version 2.3.4).
We have located the root cause of this problem and it resides in the class
src/core/org/apache/jmeter/samplers/SampleResult.java. The constructor
"SampleResult(SampleResult res)", clones the initial result to a "Parent"
result object and sets it as the child of the Parent.
During this cloning the following piece of code causes some trouble:
<code>
public SampleResult(SampleResult res) {
...
setResponseData(res.getResponseData());
...
...
addSubResult(res); // this will add res.getTime() to getTime().
...
</code>
The invocation of addSubResult in the code above does this: setBytes(getBytes()
+ subResult.getBytes()); which sets the bytes of the parent to 2x[size of
initial subresult].
Of course that is if the initial request has some body message and not just the
headers with the 30x response.
Although it's common that 30x response have no message body, it is not always
the case. And I think JMeter should give fine figures at all times.
In the patch attached to this report, I have replaced this invocation with this
code:
<code>
String tn = getThreadName();
if (tn.length()==0) {
tn=Thread.currentThread().getName();//TODO do this more efficiently
this.setThreadName(tn);
}
res.setThreadName(tn);
if (subResults == null) {
subResults = new ArrayList<SampleResult>();
}
subResults.add(res);
// Extend the time to the end of the added sample
setEndTime(res.getEndTime());
// Include the byte count for the added sample
setBytes(res.getBytes());
res.setParent(this);
</code>
which is the code of the function addSubResult but stripping out the
"getBytes()" part.
This patch has been tested over several scripts and gave fine results.
Please give it a look as you might find it useful; if so, please add it in a
next release.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]