mirror of https://github.com/apache/nifi.git
NIFI-7264 Make jsonPath Expression Logging More Reasonable
add special handling of PathNotFoundExceptions to log to debug fix spelling error wrap debug log in guard per review This closes #4148 Signed-off-by: Mike Thomsen <mthomsen@apache.org>
This commit is contained in:
parent
943de310ad
commit
23fa2d3138
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.attribute.expression.language.evaluation.functions;
|
package org.apache.nifi.attribute.expression.language.evaluation.functions;
|
||||||
|
|
||||||
|
import com.jayway.jsonpath.PathNotFoundException;
|
||||||
import org.apache.nifi.attribute.expression.language.EvaluationContext;
|
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.Evaluator;
|
||||||
import org.apache.nifi.attribute.expression.language.evaluation.QueryResult;
|
import org.apache.nifi.attribute.expression.language.evaluation.QueryResult;
|
||||||
|
@ -46,7 +47,16 @@ public class JsonPathEvaluator extends JsonPathBaseEvaluator {
|
||||||
Object result = null;
|
Object result = null;
|
||||||
try {
|
try {
|
||||||
result = documentContext.read(compiledJsonPath);
|
result = documentContext.read(compiledJsonPath);
|
||||||
|
} 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
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.debug("PathNotFoundException for JsonPath " + compiledJsonPath.getPath(), pnf);
|
||||||
|
}
|
||||||
|
return EMPTY_RESULT;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
// a failure for something *other* than path not found however, should at least be
|
||||||
|
// logged.
|
||||||
LOGGER.error("Exception while reading JsonPath " + compiledJsonPath.getPath(), e);
|
LOGGER.error("Exception while reading JsonPath " + compiledJsonPath.getPath(), e);
|
||||||
return EMPTY_RESULT;
|
return EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue