Author: pmouawad
Date: Mon Oct 29 09:23:28 2018
New Revision: 1845092

URL: http://svn.apache.org/viewvc?rev=1845092&view=rev
Log:
Bug 62860 - JSON Extractor : Avoid NPE and noisy error message "Error 
processing JSON content in" when variable is not found
Bugzilla Id: 62860

Modified:
    
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java
    jmeter/trunk/xdocs/changes.xml

Modified: 
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java?rev=1845092&r1=1845091&r2=1845092&view=diff
==============================================================================
--- 
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java
 (original)
+++ 
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java
 Mon Oct 29 09:23:28 2018
@@ -22,6 +22,7 @@ import java.io.Serializable;
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.jmeter.processor.PostProcessor;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.testelement.AbstractScopedTestElement;
@@ -101,10 +102,12 @@ public class JSONPostProcessor extends A
             String currentJsonPath = jsonPathExpressions[i].trim();
             clearOldRefVars(vars, currentRefName);
             try {
-                if (jsonResponse.isEmpty()) {
+                if (StringUtils.isEmpty(jsonResponse)) {
+                    if(log.isDebugEnabled()) {
+                        log.debug("Response or source variable is null or 
empty for {}", getName());
+                    }
                     vars.put(currentRefName, defaultValues[i]);
                 } else {
-
                     List<Object> extractedValues = localMatcher.get()
                             .extractWithJsonPath(jsonResponse, 
currentJsonPath);
                     // if no values extracted, default value added

Modified: jmeter/trunk/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1845092&r1=1845091&r2=1845092&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Mon Oct 29 09:23:28 2018
@@ -156,6 +156,7 @@ Summary
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>
 <ul>
     <li><bug>62774</bug>XPath2Extractor : Scope variable is broken. 
Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
+    <li><bug>62860</bug>JSON Extractor : Avoid NPE and noisy error message 
"Error processing JSON content in" when variable is not found</li>
 </ul>
 
 <h3>Functions</h3>


Reply via email to