Author: pmouawad
Date: Wed Dec 30 15:26:19 2015
New Revision: 1722352
URL: http://svn.apache.org/viewvc?rev=1722352&view=rev
Log:
Fix NPE during recording
Bugzilla Id: 57804
Modified:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1722352&r1=1722351&r2=1722352&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Wed Dec 30 15:26:19 2015
@@ -122,6 +122,7 @@ import org.apache.jmeter.testelement.pro
import org.apache.jmeter.testelement.property.JMeterProperty;
import org.apache.jmeter.testelement.property.PropertyIterator;
import org.apache.jmeter.threads.JMeterContextService;
+import org.apache.jmeter.threads.JMeterVariables;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.util.JsseSSLManager;
import org.apache.jmeter.util.SSLManager;
@@ -450,7 +451,11 @@ public class HTTPHC4Impl extends HTTPHCA
if(log.isDebugEnabled()) {
log.debug("Extracted from HttpContext user token:"+userToken+", storing it
as JMeter variable:"+USER_TOKEN);
}
- JMeterContextService.getContext().getVariables().putObject(USER_TOKEN, userToken);
+ // During recording JMeterContextService.getContext().getVariables() is null
+ JMeterVariables jMeterVariables = JMeterContextService.getContext().getVariables();
+ if (jMeterVariables != null) {
+ jMeterVariables.putObject(USER_TOKEN, userToken);
+ }
}
}
@@ -460,7 +465,12 @@ public class HTTPHC4Impl extends HTTPHCA
* @param localContext {@link HttpContext}
*/
private final void setupClientContextBeforeSample(HttpContext localContext) {
- Object userToken = JMeterContextService.getContext().getVariables().getObject(USER_TOKEN);
+ Object userToken = null;
+ // During recording JMeterContextService.getContext().getVariables() is null
+ JMeterVariables jMeterVariables = JMeterContextService.getContext().getVariables();
+ if(jMeterVariables != null) {
+ userToken = jMeterVariables.getObject(USER_TOKEN);
+ }
if(userToken != null) {
if(log.isDebugEnabled()) {
log.debug("Found user token:"+userToken+" as JMeter variable:"+USER_TOKEN+",
storing it in HttpContext");
|