Bug 56222

Summary: NPE if jmeter.httpclient.strict_rfc2616=true and location is not absolute
Product: JMeter - Now in Github Reporter: Sebb <sebb>
Component: HTTPAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 2.11   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description Sebb 2014-03-05 22:28:40 UTC
If jmeter.httpclient.strict_rfc2616=true and the Location: header consists of just a path (no protocol/host) then an NPE is generated:

java.lang.NullPointerException
	at org.apache.jorphan.util.JOrphanUtils.replaceAllChars(JOrphanUtils.java:264)
	at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.encodeSpaces(HTTPSamplerBase.java:1332)
	at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.followRedirects(HTTPSamplerBase.java:1404)
	at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.resultProcessing(HTTPSamplerBase.java:1482)
	at org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl.resultProcessing(HTTPAbstractImpl.java:306)
	at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:411)
	at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
	at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1105)
	at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1094)
	at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:429)
	at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:257)
	at java.lang.Thread.run(Thread.java:744)

This is because it's not possible to create a URL without a protocol, so the code skips setting the result redirectlocation. This eventually causes the NPE.

Seems to have been caused by http://svn.apache.org/r1550547 (Bug 55717)

A work-round is to save the unsantised location header in case the exception path is taken
Comment 1 Sebb 2014-03-05 22:34:21 UTC
URL: http://svn.apache.org/r1574701
Log:
NPE if jmeter.httpclient.strict_rfc2616=true and location is not absolute
Bugzilla Id: 56222

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
    jmeter/trunk/xdocs/changes.xml
Comment 2 The ASF infrastructure team 2022-09-24 20:37:56 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/3335