Author: sebb
Date: Thu Apr 21 01:42:33 2011
New Revision: 1095589
URL: http://svn.apache.org/viewvc?rev=1095589&view=rev
Log:
Avoid NPE when using HEAD method
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java?rev=1095589&r1=1095588&r2=1095589&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
Thu Apr 21 01:42:33 2011
@@ -249,9 +249,10 @@ public class HTTPHC3Impl extends HTTPHCA
res.setRequestHeaders(getConnectionHeaders(httpMethod));
// Request sent. Now get the response:
- InputStream instream = new
CountingInputStream(httpMethod.getResponseBodyAsStream());
+ InputStream instream = httpMethod.getResponseBodyAsStream();
if (instream != null) {// will be null for HEAD
+ instream = new CountingInputStream(instream);
try {
Header responseHeader =
httpMethod.getResponseHeader(HEADER_CONTENT_ENCODING);
if (responseHeader!= null &&
ENCODING_GZIP.equals(responseHeader.getValue())) {
@@ -297,7 +298,9 @@ public class HTTPHC3Impl extends HTTPHCA
}
// record some sizes to allow HTTPSampleResult.getBytes() with
different options
- res.setBodySize(((CountingInputStream) instream).getCount());
+ if (instream != null) {
+ res.setBodySize(((CountingInputStream) instream).getCount());
+ }
res.setHeadersSize(calculateHeadersSize(httpMethod));
if (log.isDebugEnabled()) {
log.debug("Response headersSize=" + res.getHeadersSize() + "
bodySize=" + res.getBodySize()
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]