[jsonpath] Fix exception when input string is empty (#15283)

Signed-off-by: Jan N. Klug <github@klug.nrw>
This commit is contained in:
J-N-K 2023-07-23 17:14:16 +02:00 committed by GitHub
parent 36741bf004
commit 4afe151108
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,6 +59,10 @@ public class JSonPathTransformationService implements TransformationService {
logger.debug("about to transform '{}' by the function '{}'", source, jsonPathExpression); logger.debug("about to transform '{}' by the function '{}'", source, jsonPathExpression);
if (source.isBlank()) {
// return null if source is empty/blank, JSONPath will throw an IAE on empty input strings
return null;
}
try { try {
Object transformationResult = JsonPath.read(source, jsonPathExpression); Object transformationResult = JsonPath.read(source, jsonPathExpression);
logger.debug("transformation resulted in '{}'", transformationResult); logger.debug("transformation resulted in '{}'", transformationResult);