mirror of
https://github.com/apache/nifi.git
synced 2025-02-06 01:58:32 +00:00
NIFI-11502 - Upgrade json-path to 2.8.0
NIFI-11502 fixing unit tests NIFI-11502 review This closes #7208 Signed-off-by: Mike Thomsen <mthomsen@apache.org>
This commit is contained in:
parent
9274d0c9b0
commit
7fb2468f4b
@ -116,7 +116,7 @@
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<version>2.6.0</version>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
|
@ -20,15 +20,20 @@ import org.apache.nifi.attribute.expression.language.EvaluationContext;
|
||||
import org.apache.nifi.attribute.expression.language.evaluation.Evaluator;
|
||||
import org.apache.nifi.attribute.expression.language.evaluation.QueryResult;
|
||||
import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import com.jayway.jsonpath.PathNotFoundException;
|
||||
|
||||
/**
|
||||
* JsonPathDeleteEvaluator allows delete elements at the specified path
|
||||
*/
|
||||
public class JsonPathDeleteEvaluator extends JsonPathBaseEvaluator {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(JsonPathDeleteEvaluator.class);
|
||||
|
||||
public JsonPathDeleteEvaluator(final Evaluator<String> subject, final Evaluator<String> jsonPathExp) {
|
||||
super(subject, jsonPathExp);
|
||||
}
|
||||
@ -42,6 +47,11 @@ public class JsonPathDeleteEvaluator extends JsonPathBaseEvaluator {
|
||||
String result = null;
|
||||
try {
|
||||
result = documentContext.delete(compiledJsonPath).jsonString();
|
||||
} catch (PathNotFoundException pnf) {
|
||||
// it is valid for a path not to be found, keys may not be there
|
||||
// do not spam the error log for this, instead we can log debug if enabled
|
||||
LOGGER.debug("JSON Path not found: {}", compiledJsonPath.getPath(), pnf);
|
||||
result = documentContext.jsonString();
|
||||
} catch (Exception e) {
|
||||
// assume the path did not match anything in the document
|
||||
return EMPTY_RESULT;
|
||||
|
@ -18,6 +18,8 @@ package org.apache.nifi.attribute.expression.language.evaluation.functions;
|
||||
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import com.jayway.jsonpath.PathNotFoundException;
|
||||
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import org.apache.nifi.attribute.expression.language.EvaluationContext;
|
||||
import org.apache.nifi.attribute.expression.language.evaluation.Evaluator;
|
||||
@ -52,6 +54,11 @@ public abstract class JsonPathUpdateEvaluator extends JsonPathBaseEvaluator {
|
||||
String result;
|
||||
try {
|
||||
result = updateAttribute(documentContext, compiledJsonPath, value).jsonString();
|
||||
} catch (PathNotFoundException pnf) {
|
||||
// it is valid for a path not to be found, keys may not be there
|
||||
// do not spam the error log for this, instead we can log debug if enabled
|
||||
LOGGER.debug("JSON Path not found: {}", compiledJsonPath.getPath(), pnf);
|
||||
result = documentContext.jsonString();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Failed to update attribute " + e.getLocalizedMessage(), e);
|
||||
// assume the path did not match anything in the document
|
||||
|
@ -121,7 +121,7 @@
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<version>2.7.0</version>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
|
@ -89,7 +89,7 @@ language governing permissions and limitations under the License. -->
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<version>2.7.0</version>
|
||||
<version>2.8.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<version>2.6.0</version>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
|
@ -184,7 +184,7 @@
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<version>2.6.0</version>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tika</groupId>
|
||||
|
Loading…
x
Reference in New Issue
Block a user