From 4afe1511085b6617582549b9d207c7b7aff61b3e Mon Sep 17 00:00:00 2001 From: J-N-K Date: Sun, 23 Jul 2023 17:14:16 +0200 Subject: [PATCH] [jsonpath] Fix exception when input string is empty (#15283) Signed-off-by: Jan N. Klug --- .../jsonpath/internal/JSonPathTransformationService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bundles/org.openhab.transform.jsonpath/src/main/java/org/openhab/transform/jsonpath/internal/JSonPathTransformationService.java b/bundles/org.openhab.transform.jsonpath/src/main/java/org/openhab/transform/jsonpath/internal/JSonPathTransformationService.java index 91939afa968..a38bf650324 100644 --- a/bundles/org.openhab.transform.jsonpath/src/main/java/org/openhab/transform/jsonpath/internal/JSonPathTransformationService.java +++ b/bundles/org.openhab.transform.jsonpath/src/main/java/org/openhab/transform/jsonpath/internal/JSonPathTransformationService.java @@ -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);