Bug 65053

Summary: JSONPath Tester doesn't work for some expressions due to updated json-path-2.5.0.jar
Product: JMeter Reporter: eR@SeR <nalexic>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: normal CC: p.mouawad
Priority: P2 Keywords: FixedInTrunk
Version: Nightly (Please specify date)   
Target Milestone: JMETER 5.4.1   
Hardware: All   
OS: All   

Description eR@SeR 2021-01-03 23:48:02 UTC
Hello,

Updated json-path-2.5.0.jar in latest nightly is not executing some json path expressions:

$.store.book[?(@.price>=8 && @.category=~ /.*reference.*/)] OK
$.store.book[?(@.price>=8 || @.category=~ /.*reference.*/)] OK
$.store.book[?(@.category=~ /.*reference.*/ && @.price>=8)] doesn't work
$.store.book[?(@.category=~ /.*reference.*/ || @.price>=8)] doesn't work
$.store.book[?(@.category=~ /.*reference.*/ && @.price=~/-.+/)] doesn't work
$.store.book[?(@.category=~ /.*reference.*/ || @.price=~/-.+/)] doesn't work

Example JSON can be found here: https://github.com/json-path/JsonPath#path-examples

Error in JSONPath Tester in VRT is "Exception: Expected character: )" and when test is executed "ERROR o.a.j.e.j.j.JSONPostProcessor: Error processing JSON content in JSON Extractor, message: Expected character: )"

One of my tests relies on two regexes like $.store.book[?(@.category=~ /.*reference.*/ && @.price=~/-.+/)] so extractions that were OK in 5.3, in newest nightly are failing. If two regexes are a must, there is no workaround I guess. Please consider reverting to json-path-2.4.0.jar until the issue is resolved.

Someone already reported it - https://github.com/json-path/JsonPath/issues/658

P.S. Nice to see Jayway JsonPath project gets revived after few years of inactivity. Looking forward to seeing the resolution of https://github.com/json-path/JsonPath/issues/287 :)

Jmeter 5.3
Jmeter 5.4.1 c990226
Microsoft Windows 10 Enterprise 64-bit
java version "14.0.1" 2020-04-14
Comment 1 Felix Schumacher 2021-01-04 14:12:52 UTC
That seems to be https://github.com/json-path/JsonPath/issues/658
Comment 2 Felix Schumacher 2021-01-04 14:52:03 UTC
The stacktrace on that error would be:

2021-01-04 15:47:08,037 ERROR o.a.j.e.j.j.JSONPostProcessor: Error processing JSON content in JSON Extractor, message: Expected character: )
com.jayway.jsonpath.InvalidPathException: Expected character: )
	at com.jayway.jsonpath.internal.CharacterIndex.readSignificantChar(CharacterIndex.java:218) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.filter.FilterCompiler.readLogicalANDOperand(FilterCompiler.java:182) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.filter.FilterCompiler.readLogicalAND(FilterCompiler.java:150) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.filter.FilterCompiler.readLogicalOR(FilterCompiler.java:132) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.filter.FilterCompiler.compile(FilterCompiler.java:78) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.filter.FilterCompiler.compile(FilterCompiler.java:54) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.path.PathCompiler.readFilterToken(PathCompiler.java:461) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.path.PathCompiler.readNextToken(PathCompiler.java:141) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.path.PathCompiler.readPropertyOrFunctionToken(PathCompiler.java:237) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.path.PathCompiler.readNextToken(PathCompiler.java:151) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.path.PathCompiler.readDotToken(PathCompiler.java:171) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.path.PathCompiler.readNextToken(PathCompiler.java:145) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.path.PathCompiler.readPropertyOrFunctionToken(PathCompiler.java:237) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.path.PathCompiler.readNextToken(PathCompiler.java:151) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.path.PathCompiler.readDotToken(PathCompiler.java:171) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.path.PathCompiler.readNextToken(PathCompiler.java:145) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.path.PathCompiler.readContextToken(PathCompiler.java:124) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.path.PathCompiler.compile(PathCompiler.java:58) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.path.PathCompiler.compile(PathCompiler.java:75) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.JsonPath.<init>(JsonPath.java:101) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.JsonPath.compile(JsonPath.java:467) ~[json-path-2.4.0.jar:2.4.0]
	at org.apache.jmeter.extractor.json.jsonpath.JSONManager.lambda$getJsonPath$0(JSONManager.java:56) ~[ApacheJMeter_components.jar:5.4.1-SNAPSHOT]
	at java.util.HashMap.computeIfAbsent(HashMap.java:1127) ~[?:1.8.0_201]
	at org.apache.jmeter.extractor.json.jsonpath.JSONManager.getJsonPath(JSONManager.java:56) ~[ApacheJMeter_components.jar:5.4.1-SNAPSHOT]
	at org.apache.jmeter.extractor.json.jsonpath.JSONManager.extractWithJsonPath(JSONManager.java:72) ~[ApacheJMeter_components.jar:5.4.1-SNAPSHOT]
	at org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor.process(JSONPostProcessor.java:83) [ApacheJMeter_components.jar:5.4.1-SNAPSHOT]
	at org.apache.jmeter.threads.JMeterThread.runPostProcessors(JMeterThread.java:955) [ApacheJMeter_core.jar:5.4.1-SNAPSHOT]
	at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:573) [ApacheJMeter_core.jar:5.4.1-SNAPSHOT]
	at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489) [ApacheJMeter_core.jar:5.4.1-SNAPSHOT]
	at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) [ApacheJMeter_core.jar:5.4.1-SNAPSHOT]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]
Comment 3 Philippe Mouawad 2021-01-10 15:55:30 UTC
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 94c8ffe  Revert json-path to version 2.4.0
94c8ffe is described below

commit 94c8ffedde95fb16eb2da39c90e51233a82b61b7
Author: Felix Schumacher <felix.schumacher@internetallee.de>
AuthorDate: Sat Jan 9 18:30:52 2021 +0100

    Revert json-path to version 2.4.0

    The newer version 2.5.0 has a bug https://github.com/json-path/JsonPath/issues/658
    which surfaces when using regexes in the expressions.

    Bugzilla Id: 65053
---
 gradle.properties | 2 +-
 xdocs/changes.xml | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)