fjtirado commented on code in PR #3696:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/3696#discussion_r1793301635


##########
kogito-serverless-workflow/kogito-jsonpath-expression/src/main/java/org/kie/kogito/expr/jsonpath/JsonPathExpression.java:
##########
@@ -61,24 +63,28 @@ private Configuration getConfiguration(KogitoProcessContext 
context) {
                 .build();
     }
 
+    private static boolean isContextAware(JsonNode context, Map<String, 
JsonNode> additionalVars) {
+        return !additionalVars.isEmpty() && context instanceof ObjectNode;
+    }
+
     private <T> T eval(JsonNode context, Class<T> returnClass, 
KogitoProcessContext processInfo) {
-        try (JsonNodeContext jsonNode = JsonNodeContext.from(context, 
processInfo)) {
-            Configuration jsonPathConfig = getConfiguration(processInfo);
-            DocumentContext parsedContext = 
JsonPath.using(jsonPathConfig).parse(jsonNode.getNode());
-            if (String.class.isAssignableFrom(returnClass)) {
-                StringBuilder sb = new StringBuilder();
-                // valid json path is $. or $[
-                for (String part : expr.split("((?=\\$\\.|\\$\\[))")) {
-                    JsonNode partResult = parsedContext.read(part, 
JsonNode.class);
-                    sb.append(partResult.isTextual() ? partResult.asText() : 
partResult.toPrettyString());
-                }
-                return (T) sb.toString();
-            } else {
-                Object result = parsedContext.read(expr);
-                return Boolean.class.isAssignableFrom(returnClass) && result 
instanceof ArrayNode ? (T) Boolean.valueOf(!((ArrayNode) result).isEmpty())
-                        : 
JsonObjectUtils.convertValue(jsonPathConfig.mappingProvider().map(result, 
returnClass, jsonPathConfig), returnClass);
+
+        Configuration jsonPathConfig = getConfiguration(processInfo);
+        DocumentContext parsedContext = 
JsonPath.using(jsonPathConfig).parse(context);
+        if (String.class.isAssignableFrom(returnClass)) {
+            StringBuilder sb = new StringBuilder();
+            // valid json path is $. or $[
+            for (String part : expr.split("((?=\\$\\.|\\$\\[))")) {
+                JsonNode partResult = parsedContext.read(part, JsonNode.class);

Review Comment:
   The expression will fail and also this instance execution. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to