You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2016/07/12 17:11:08 UTC

svn commit: r1752317 - in /jmeter/trunk: src/components/org/apache/jmeter/extractor/json/jsonpath/JSONManager.java xdocs/changes.xml

Author: fschumacher
Date: Tue Jul 12 17:11:08 2016
New Revision: 1752317

URL: http://svn.apache.org/viewvc?rev=1752317&view=rev
Log:
Log messages about JSON Path mismatches at debug level instead of error.

Bugzilla Id: 59845

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

Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONManager.java?rev=1752317&r1=1752316&r2=1752317&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONManager.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONManager.java Tue Jul 12 17:11:08 2016
@@ -20,16 +20,21 @@ package org.apache.jmeter.extractor.json
 
 import java.text.ParseException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
 import net.minidev.json.JSONArray;
 import net.minidev.json.JSONObject;
 
 import com.jayway.jsonpath.Configuration;
 import com.jayway.jsonpath.JsonPath;
 import com.jayway.jsonpath.Option;
+import com.jayway.jsonpath.PathNotFoundException;
 
 /**
  * Handles the extractions
@@ -37,6 +42,8 @@ import com.jayway.jsonpath.Option;
  * @since 3.0
  */
 public class JSONManager {
+
+    private static final Logger log = LoggingManager.getLoggerForClass();
     private static final Configuration DEFAULT_CONFIGURATION =
             Configuration.defaultConfiguration().addOptions(Option.ALWAYS_RETURN_LIST);
     /**
@@ -70,8 +77,17 @@ public class JSONManager {
     public List<Object> extractWithJsonPath(String jsonString, String jsonPath)
             throws ParseException {
         JsonPath jsonPathParser = getJsonPath(jsonPath);
-        List<Object> extractedObjects = jsonPathParser.read(jsonString,
-                DEFAULT_CONFIGURATION);
+        List<Object> extractedObjects;
+        try {
+            extractedObjects = jsonPathParser.read(jsonString,
+                    DEFAULT_CONFIGURATION);
+        } catch (PathNotFoundException e) {
+            if (log.isDebugEnabled()) {
+                log.debug("Could not find JSON Path " + jsonPath + " in ["
+                        + jsonString + "]: " + e.getLocalizedMessage());
+            }
+            return Collections.emptyList();
+        }
         List<Object> results = new ArrayList<>(extractedObjects.size());
         for (Object obj: extractedObjects) {
             results.add(stringifyJSONObject(obj));

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1752317&r1=1752316&r2=1752317&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Tue Jul 12 17:11:08 2016
@@ -98,6 +98,7 @@ Summary
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>
 <ul>
     <li><bug>59609</bug>Format extracted JSON Objects in JSON Post Processor correctly as JSON.</li>
+    <li><bug>59845</bug>Log messages about JSON Path mismatches at <code>debug</code> level instead of <code>error</code>.</li>
 </ul>
 
 <h3>Functions</h3>