apache / incubator-kie-drools

Drools is a rule engine, DMN engine and complex event processing (CEP) engine for Java.
http://www.drools.org
5.85k stars 2.49k forks source link

`for` expression with a `null` leads to unexpected NPE #5968

Closed yesamer closed 4 months ago

yesamer commented 4 months ago

Closes https://github.com/apache/incubator-kie-issues/issues/1246

Screenshot 2024-05-22 at 16 38 00 Screenshot 2024-05-22 at 17 12 14

The NPE is thrown because of ´expression.getTypeRef().toString().toLowerCase()`, in such a case the typeRef is null

Considering that:

To fix the issue it's enough to pass the constants that represent the variable name (variableIterator)

@gitgabrio @baldimir Do you have any idea how I can effectively test this change?

After:

Screenshot 2024-05-22 at 16 38 42

Before:

Screenshot 2024-05-22 at 16 54 31