jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject [jmeter] branch master updated: JMESPathExtractor writes error log entries if JMESPath filter returns empty result
Date Sat, 24 Apr 2021 10:25:21 GMT
This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new 4206445  JMESPathExtractor writes error log entries if JMESPath filter returns empty
result
4206445 is described below

commit 4206445d058b1e1cbae8e71f07c5f6d1e2e91935
Author: Felix Schumacher <felix.schumacher@internetallee.de>
AuthorDate: Sat Apr 24 12:24:43 2021 +0200

    JMESPathExtractor writes error log entries if JMESPath filter returns empty result
    
    Second try to fix the bug.
    
    Bugzilla Id: 65257
---
 .../org/apache/jmeter/extractor/json/jmespath/JMESPathExtractor.java  | 4 +++-
 .../apache/jmeter/extractor/json/jmespath/TestJMESPathExtractor.java  | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/components/src/main/java/org/apache/jmeter/extractor/json/jmespath/JMESPathExtractor.java
b/src/components/src/main/java/org/apache/jmeter/extractor/json/jmespath/JMESPathExtractor.java
index 8e25c0f..a1e5eea 100644
--- a/src/components/src/main/java/org/apache/jmeter/extractor/json/jmespath/JMESPathExtractor.java
+++ b/src/components/src/main/java/org/apache/jmeter/extractor/json/jmespath/JMESPathExtractor.java
@@ -79,7 +79,7 @@ public class JMESPathExtractor extends AbstractScopedTestElement
         try {
             JsonNode actualObj = OBJECT_MAPPER.readValue(jsonResponse, JsonNode.class);
             JsonNode result = JMESPathCache.getInstance().get(jsonPathExpression).search(actualObj);
-            if (result.isNull() || result.isEmpty()) {
+            if (result.isNull()) {
                 handleNullResult(vars, refName, defaultValue, matchNumber);
                 return;
             }
@@ -87,6 +87,8 @@ public class JMESPathExtractor extends AbstractScopedTestElement
             // if more than one value extracted, suffix with "_index"
             if (resultList.size() > 1) {
                 handleListResult(vars, refName, defaultValue, matchNumber, resultList);
+            } else if (resultList.isEmpty()){
+                // no value extracted. Use defaultValue
             } else {
                 // else just one value extracted
                 handleSingleResult(vars, refName, matchNumber, resultList);
diff --git a/src/components/src/test/java/org/apache/jmeter/extractor/json/jmespath/TestJMESPathExtractor.java
b/src/components/src/test/java/org/apache/jmeter/extractor/json/jmespath/TestJMESPathExtractor.java
index bc58d58..87f72d0 100644
--- a/src/components/src/test/java/org/apache/jmeter/extractor/json/jmespath/TestJMESPathExtractor.java
+++ b/src/components/src/test/java/org/apache/jmeter/extractor/json/jmespath/TestJMESPathExtractor.java
@@ -73,7 +73,7 @@ public class TestJMESPathExtractor {
     @RunWith(Parameterized.class)
     public static class OneMatchOnAllExtractedValues {
 
-        @Parameters
+        @Parameters(name = "Extract from {0} with path {1} should result in {2} for match
{3}")
         public static Collection<String[]> data() {
             return Arrays.asList(new String[][] {
                 {"[\"one\"]", "[*]", "one", "1"},

Mime
View raw message