Bug 41902 - NPE when status code == -1
Summary: NPE when status code == -1
Alias: None
Product: JMeter
Classification: Unclassified
Component: HTTP (show other bugs)
Version: Nightly (Please specify date)
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL: http://www.nabble.com/HTTP-response-c...
Depends on:
Reported: 2007-03-20 06:07 UTC by Andreas Laager
Modified: 2007-03-23 16:40 UTC (History)
0 users

JMeter Test Plan (7.64 KB, text/plain)
2007-03-20 06:09 UTC, Andreas Laager
Log file with NullPointerException (debug) (120.79 KB, application/octet-stream)
2007-03-20 06:10 UTC, Andreas Laager

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Laager 2007-03-20 06:07:38 UTC
Nightly Build: r516517

I try to request an https site. If I request the home (e.g 
https://myServer/home/) I get redirected to the page I want 
(e.g. .../home/page1) but with response code -1. If I request the page directly 
(https://myServer/home/page1) I get nothing back in the results tree, not even 
an entry in the tree on the left side. The only thing I found is a 
NullPointerException in the JMeter.log.
Comment 1 Andreas Laager 2007-03-20 06:09:23 UTC
Created attachment 19753 [details]
JMeter Test Plan
Comment 2 Andreas Laager 2007-03-20 06:10:30 UTC
Created attachment 19754 [details]
Log file with NullPointerException (debug)
Comment 3 Sebb 2007-03-20 06:26:12 UTC
Looks like the problem is caused by the following code:

  int errorLevel = conn.getResponseCode();
  String respMsg = conn.getResponseMessage();
  if (errorLevel == -1){// Bug 38902 - sometimes -1 seems to be returned 
   try {
      errorLevel = Integer.parseInt(respMsg.substring(0, 3)); <== NPE

So the server must have returned -1 as the response Code, and not provided a 
response message.

I'll fix the code to check for respMsg being null.

It may be possible to still get the first header line, in which case that can 
be logged.

I should be able to generate a new nightly this evening.
Comment 4 Sebb 2007-03-20 13:41:45 UTC
I've applied some fixes to SVN; these will be in the nightly after r520560.

By the way, the test plan was no use, because there does not seem to be any 
access to the server - at least its name is not in external DNS servers.

So please can you check if the fix has worked?
Comment 5 Andreas Laager 2007-03-21 03:52:18 UTC
Now, it seems to work fine. I get all results in the result tree for every http 
request I send. I'm still wondering why I get a -1 back but that is a problem 
on our side.

Tested in: r520565

Thanks for the quick help.
Comment 6 Sebb 2007-03-21 05:31:11 UTC
Glad that's sorted the NPE.

I put in a log to hopefully show the HTTP header line (and that should also 
appear in the View Results Tree) - can you please have a look and see what it 

That will hopefully give a better clue as to what is going on. Thanks.
Comment 7 Andreas Laager 2007-03-21 06:03:13 UTC
That was in the log:
WARN  - jmeter.util.HttpSSLProtocolSocketFactory: Could not set protocol list:
WARN  - jmeter.util.HttpSSLProtocolSocketFactory: Valid protocols are: 
SSLv2Hello SSLv3 TLSv1   
WARN  - jmeter.protocol.http.sampler.HTTPSampler: ResponseCode==-1; could not 
parse Found   
WARN  - jmeter.protocol.http.sampler.HTTPSampler: ResponseCode==-1 & null 
ResponseMessage. Header(0)= HTTP/1.1   
WARN  - jmeter.protocol.http.sampler.HTTPSampler: ResponseCode==-1 & null 
ResponseMessage. Header(0)= HTTP/1.1   
WARN  - jmeter.protocol.http.sampler.HTTPSampler: ResponseCode==-1 & null 
ResponseMessage. Header(0)= HTTP/1.1

The valid protocol 'SSLv2Hello' looks funny to me. Do I have to specify the 
ssl/tls version?
Comment 8 Sebb 2007-03-21 06:49:37 UTC
Looks like the server is only returning


instead of

HTTP/1.1 200 OK

or similar.

Not sure where the "Found" comes from. I think I need to change that log 
message to show the full header.

The log messages from HttpSSLProtocolSocketFactory are temporary, and can be 
ignored (but thanks for reporting them!)
Comment 9 Sebb 2007-03-21 16:11:26 UTC
The sampler now logs the full header for the parse failure case, so it should 
be easier to see what is happening.

I've fixed the HttpSSLProtocolSocketFactory warning.

This will be in the nightly builds after r521029.
Comment 10 Andreas Laager 2007-03-22 01:49:14 UTC
Tested in r521053:
HttpSSLProtocolSocketFactory warning doesn't show up anymore. 

Now I get this in the log file:
HTTPSampler: ResponseCode==-1; could not parse Found hdr: HTTP/1.1 

With the 'IE HTTPAnalyser V2' I analysed the HTTP header I get from our server. 
It looks like the response is only: 'HTTP/1.1' where on 'healthy' server it 
is 'HTTP/1.1 200 OK'.

So in my opinion the correct values for this response should be:
HTTP response code: (none)
HTTP response message: (none)

But abart from this minor issue JMeter is working fine and I start to like it:-)
Comment 11 Sebb 2007-03-22 03:51:29 UTC
I wonder where the "Found" text is coming from? 
JMeter gets it from the responseMessage, which should come from the header - 
but it is not in the header...

Good idea regarding using (none) for the JMeter code and message; I'll see 
about adding that.