Skip to content

Commit 716587d

Browse files
MikeThomsenjoewitt
authored andcommitted
NIFI-5169 This closes #2705. Upgrade to JSONPath 2.4
NIFI-5169 Added explicit checking for empty strings in JsonPath expression property. Signed-off-by: joewitt <[email protected]>
1 parent 06d45c3 commit 716587d

File tree

6 files changed

+52
-511
lines changed

6 files changed

+52
-511
lines changed

nifi-commons/nifi-expression-language/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<dependency>
7777
<groupId>com.jayway.jsonpath</groupId>
7878
<artifactId>json-path</artifactId>
79-
<version>2.0.0</version>
79+
<version>2.4.0</version>
8080
</dependency>
8181
<dependency>
8282
<groupId>com.fasterxml.jackson.core</groupId>

nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AbstractJsonPathProcessor.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import org.apache.nifi.processor.AbstractProcessor;
3030
import org.apache.nifi.processor.ProcessSession;
3131
import org.apache.nifi.processor.io.InputStreamCallback;
32-
import org.apache.nifi.processors.standard.util.JsonPathExpressionValidator;
3332
import org.apache.nifi.stream.io.BufferedInputStream;
33+
import org.apache.nifi.util.StringUtils;
3434

3535
import java.io.IOException;
3636
import java.io.InputStream;
@@ -112,11 +112,15 @@ abstract static class JsonPathValidator implements Validator {
112112
public ValidationResult validate(final String subject, final String input, final ValidationContext context) {
113113
String error = null;
114114
if (isStale(subject, input)) {
115-
if (JsonPathExpressionValidator.isValidExpression(input)) {
116-
JsonPath compiledJsonPath = JsonPath.compile(input);
117-
cacheComputedValue(subject, input, compiledJsonPath);
115+
if (!StringUtils.isBlank(input)) {
116+
try {
117+
JsonPath compiledJsonPath = JsonPath.compile(input);
118+
cacheComputedValue(subject, input, compiledJsonPath);
119+
} catch (Exception ex) {
120+
error = String.format("specified expression was not valid: %s", input);
121+
}
118122
} else {
119-
error = "specified expression was not valid: " + input;
123+
error = "the expression cannot be empty.";
120124
}
121125
}
122126
return new ValidationResult.Builder().subject(subject).valid(error == null).explanation(error).build();

0 commit comments

Comments
 (0)