Copilot commented on code in PR #4101:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4101#discussion_r2446846183


##########
jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/rule/DecisionRuleTypeEngineImpl.java:
##########
@@ -68,4 +69,28 @@ public void evaluate(RuleSetNodeInstance rsni, String 
inputNamespace, String inp
 
         rsni.triggerCompleted();
     }
+
+    private Map<String, Object> getDMNAnnotatedAdjustedMap(RuleSetNodeInstance 
rsni) {
+        // Get inputs
+        Map<String, Object> inputs = getInputs(rsni);
+        // resolve inputs with the JsonResolver' objectMapper
+        Map<String, Object> toReturn = jsonResolver.resolveAll(inputs);
+        // Retrieving DMN-annotated inputs
+        Map<String, Object> dmnAnnotatedBeans = inputs.entrySet()
+                .stream()
+                .filter(entry -> isDMNAnnotatedBean(entry.getKey()))
+                .collect(Collectors.toMap(Map.Entry::getKey, 
Map.Entry::getValue));
+        // replacing/adding DMN-annotated beans inside returned Map
+        toReturn.putAll(dmnAnnotatedBeans);
+        return toReturn;
+    }
+
+    private boolean isDMNAnnotatedBean(Object bean) {
+        return bean != null && isDMNAnnotatedBean(bean.getClass());
+    }
+
+    private boolean isDMNAnnotatedBean(Class<?> clazz) {
+        return JavaBackedType.of(clazz).equals(BuiltInType.UNKNOWN);

Review Comment:
   The logic appears inverted: 
`JavaBackedType.of(clazz).equals(BuiltInType.UNKNOWN)` returns `true` for 
classes that are NOT recognized as Java-backed types. This would incorrectly 
identify non-DMN-annotated beans as DMN-annotated. The condition should likely 
be `!JavaBackedType.of(clazz).equals(BuiltInType.UNKNOWN)` to identify actual 
DMN-annotated beans.
   ```suggestion
           return !JavaBackedType.of(clazz).equals(BuiltInType.UNKNOWN);
   ```



##########
jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/rule/DecisionRuleTypeEngineImpl.java:
##########
@@ -68,4 +69,28 @@ public void evaluate(RuleSetNodeInstance rsni, String 
inputNamespace, String inp
 
         rsni.triggerCompleted();
     }
+
+    private Map<String, Object> getDMNAnnotatedAdjustedMap(RuleSetNodeInstance 
rsni) {
+        // Get inputs
+        Map<String, Object> inputs = getInputs(rsni);
+        // resolve inputs with the JsonResolver' objectMapper
+        Map<String, Object> toReturn = jsonResolver.resolveAll(inputs);
+        // Retrieving DMN-annotated inputs
+        Map<String, Object> dmnAnnotatedBeans = inputs.entrySet()
+                .stream()
+                .filter(entry -> isDMNAnnotatedBean(entry.getKey()))

Review Comment:
   The filter is checking `entry.getKey()` (a String) instead of 
`entry.getValue()` (the actual bean object). To identify DMN-annotated beans, 
the check should be `isDMNAnnotatedBean(entry.getValue())` since the annotation 
is on the bean class, not the key string.
   ```suggestion
                   .filter(entry -> isDMNAnnotatedBean(entry.getValue()))
   ```



-- 
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