]> git.basschouten.com Git - openhab-addons.git/commitdiff
[jsonpath] Fix exception when input string is empty (#15283)
authorJ-N-K <github@klug.nrw>
Sun, 23 Jul 2023 15:14:16 +0000 (17:14 +0200)
committerGitHub <noreply@github.com>
Sun, 23 Jul 2023 15:14:16 +0000 (17:14 +0200)
Signed-off-by: Jan N. Klug <github@klug.nrw>
bundles/org.openhab.transform.jsonpath/src/main/java/org/openhab/transform/jsonpath/internal/JSonPathTransformationService.java

index 91939afa968bfff250f16c15b46b63725b6e7320..a38bf65032464b5c9ce25b470ab3966af312253f 100644 (file)
@@ -59,6 +59,10 @@ public class JSonPathTransformationService implements TransformationService {
 
         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 {
             Object transformationResult = JsonPath.read(source, jsonPathExpression);
             logger.debug("transformation resulted in '{}'", transformationResult);