philipdnichols opened a new issue, #6448:
URL: https://github.com/apache/incubator-kie-drools/issues/6448

   ## Issue Details
   
   **Affected Version:** 10.1.0
   
   **Component:** kie-dmn-core
   
   ## Description
   
   When implementing a custom DMN runtime event listener (extending 
`DefaultDMNRuntimeEventListener`) to log decision service execution, the 
utility method `DMNEventUtils.extractDSOutputDecisionsValues()` throws a 
NullPointerException when processing decision services from models that include 
other models with different namespaces.
   
   ## Use Case
   
   We use a custom logging listener to capture decision service inputs/outputs 
for audit and debugging purposes:
   
   ```java
   public class DecisionLoggingListener extends DefaultDMNRuntimeEventListener {
       @Override
       public void 
afterEvaluateDecisionService(AfterEvaluateDecisionServiceEvent event) {
           var outputs = DMNEventUtils.extractDSOutputDecisionsValues(event);
           logger.debug("Decision Service outputs: " + outputs);
           // ... additional logging logic
       }
   }
   ```
   
   ## Root Cause
   
   The method at line 70 of `org.kie.dmn.core.impl.DMNEventUtils` calls 
`getDecisionById(id).getName()` without checking if `getDecisionById(id)` 
returns null. When decision IDs contain namespace information from included 
models, `getDecisionById()` returns null because it cannot find decisions with 
namespace-prefixed IDs, causing the NPE.
   
   ## Stack Trace
   
   ```
   java.lang.NullPointerException: Cannot invoke 
"org.kie.dmn.api.core.ast.DecisionNode.getName()" because the return value of 
"org.kie.dmn.api.core.DMNModel.getDecisionById(String)" is null
       at 
org.kie.dmn.core.impl.DMNEventUtils.extractDSOutputDecisionsValues(DMNEventUtils.java:70)
       at 
com.example.DecisionLoggingListener.afterEvaluateDecisionService(DecisionLoggingListener.java:xx)
       at 
org.kie.dmn.core.impl.DMNRuntimeEventManagerUtils.fireAfterEvaluateDecisionService(DMNRuntimeEventManagerUtils.java:81)
       at 
org.kie.dmn.core.ast.DMNDecisionServiceEvaluator.evaluate(DMNDecisionServiceEvaluator.java:111)
   ```
   
   ## Steps to Reproduce
   
   1. Create a parent DMN model that includes a child model from a different 
namespace
   2. Have the child model contain a decision service with output decisions
   3. Register a custom DMN runtime listener that calls 
`DMNEventUtils.extractDSOutputDecisionsValues()` in 
`afterEvaluateDecisionService()`
   4. Evaluate the decision service
   5. The listener's event processing will fail with NPE
   
   ## Expected Behavior
   
   The `DMNEventUtils.extractDSOutputDecisionsValues()` utility method should 
safely handle namespace-prefixed decision IDs and extract output values 
correctly for use in logging listeners.
   
   ## Actual Behavior
   
   NPE is thrown when attempting to call getName() on a null DecisionNode, 
breaking the logging functionality.
   
   ## Impact
   
   This prevents proper logging/auditing of decision service executions when 
using included models, which is a common pattern in complex DMN implementations.
   
   ## Workaround
   
   Implement a custom extraction method in the logging listener that handles 
null returns from getDecisionById() with fallback strategies instead of using 
the utility method.


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