Bug 38902 - Workaround for HTTPSampler when getReponseCode returns -1
Summary: Workaround for HTTPSampler when getReponseCode returns -1
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: unspecified
Hardware: All All
: P2 minor (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
Depends on:
Reported: 2006-03-08 23:24 UTC by sumit shah
Modified: 2006-03-08 15:53 UTC (History)
0 users

Patch to HTTPSampler.java (853 bytes, patch)
2006-03-08 23:24 UTC, sumit shah
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sumit shah 2006-03-08 23:24:22 UTC
In our own usage sometimes the call to conn.getResponseCode(); would return -1
for no apparent reason when in fact the responseCode was 200.  We could not pin
down the source of this problem and had to hadd the following lines to parse the
HTTP Response Message and use that as the response code.

      if(errorLevel == - 1) {
        try {
          int code = Integer.parseInt(res.getResponseMessage().substring(0, 3));
          res.setSuccessful(200 <= code && code <= 399);
        } catch (Exception e) {

Obviously this is a hack, but I'm sending this out in case anyone else 
runs across this and wants to see how we worked around it.

FYI patch works on trunk and 2.1.1 branch as of this writing.
Comment 1 sumit shah 2006-03-08 23:24:44 UTC
Created attachment 17852 [details]
Patch to HTTPSampler.java
Comment 2 Sebb 2006-03-08 23:37:18 UTC
It's a bit odd, because the Java code appears to be doing much the same.

I'll add the code, but log a warning to show that the return code has been
Comment 3 Sebb 2006-03-08 23:53:21 UTC
Thanks, a fix has been committed to the 2.1 branch