Closed samuel-beniamin closed 2 months ago
Hi @yesamer @samuel-beniamin could you please clarify a little bit a term MID (Multi Instance Decision)? I think it is a new for me. Is there a xml/dmn file of such model? My intention is to double-check opening such model in KIE tooling. Thank you.
@samuel-beniamin Could you please clarify if this issue relates to some implementation bug, or to the usage in some test ? I have the impression is the latter, but it is not clear at all...
Hi @yesamer @samuel-beniamin could you please clarify a little bit a term MID (Multi Instance Decision)? I think it is a new for me. Is there a xml/dmn file of such model? My intention is to double-check opening such model in KIE tooling. Thank you.
Sure, it is a concept introduced by Signavio, inside Signavio DMN extension that allows iterating over a list of input values, executing a decision table, finally deciding the operation to do with the results after each iteration (e.g. collect, sum, max). Long
You can read more about it here https://www.signavio.com/post/decision-modeling-and-the-breakthrough-power-of-the-multi-instance-decision-mid/
For an example, please check the test resources under the following directory incubator-kie-drools/kie-dmn/kie-dmn-signavio/src/test/resources/org/kie/dmn/signavio. I hope that helps, please reach out if you need more information.
@samuel-beniamin Could you please clarify if this issue relates to some implementation bug, or to the usage in some test ? I have the impression is the latter, but it is not clear at all...
Hello @gitgabrio it is actually an implementation bug, I would claim in the compiler is not checking which model is it currently evaluating, and this just calls the call back. I prevented the call in the callback itself, but maybe the proper fix should be in the DMNCompilerImpl
.
Nonetheless, the fix is simple yes, just skip the call back if this is a call for a different model by:
if (cModel != model) {
// Logs are secondary to skipping the rest of the execution.
return;
}
Current behaviour
Currently when trying to load multiple DMN in a certain order, where an XML file that contain a MID (Multi Instance Decision) loads first, then load another XML file. We get the following exception:
What, after some debug, I see is happening:
After the introduction of the
afterDRGcallbacks
in theDMNCompilerImpl
. TheMultiInstanceDecisionLogic
decided to use the callbacks. Which adds a callback to theDMNCompilerImpl
which in turn executes this callback regardless of which model it is evaluating currently. This lead to the evaluation of some callbacks, which were originally registered/added for the MID on some other models. This leads to a NPE when trying to execute the call back on a different model.Expected behaviour
Load multiple models from XML that contain MIDs and non MIDs in a any order, then we are able to build a
KieBuilder
for them all.How to reproduce?
Load multiple files with Mids into a single runtime: