]
Mario Fusco updated DROOLS-3794:
--------------------------------
Sprint: (was: 2019 Week 11-13)
Inconsistent null check between JITed and non-JITed
"contains"/"memberOf" condition
-----------------------------------------------------------------------------------
Key: DROOLS-3794
URL:
https://issues.jboss.org/browse/DROOLS-3794
Project: Drools
Issue Type: Bug
Affects Versions: 7.19.0.Final
Reporter: Max Zerzouri
Assignee: Mario Fusco
Priority: Major
Attachments: DroolsTest.java, drl.drl
A condition such as {{list contains item}} or {{item memberOf list}} seems to correspond
to {{EvaluatorHelper.contains(list, item)}}, but when this has been compiled through
{{ASMConditionEvaluatorJitter}}, the condition includes the additional constraint, {{item
!= null}}. This differs to the non-JITed condition, which does not require {{item}} to be
non-null.
Attached an example {{.drl}} file as an example case, and a simple runner. Running {{java
DroolsTest 14}} triggers the issue for me (resulting in an infinite loop in this case),
but since the recompilation is asynchronous, it might require a larger number.
Decompiled {{ConditionalEvaluator}} for the test case below:
{code:java}
import droolstest.Bar;
import droolstest.Foo;
import java.util.List;
import org.drools.core.common.InternalFactHandle;
import org.drools.core.common.InternalWorkingMemory;
import org.drools.core.rule.Declaration;
import org.drools.core.rule.constraint.ConditionEvaluator;
import org.drools.core.rule.constraint.EvaluatorHelper;
import org.drools.core.spi.Tuple;
public class ConditionEvaluator4471f59df9b54235ba1be708b5c480da
implements ConditionEvaluator {
private static final String EXPRESSION = "!( foo.barNames contains name
)";
private final Declaration[] declarations;
public boolean evaluate(InternalFactHandle internalFactHandle, InternalWorkingMemory
internalWorkingMemory, Tuple tuple) {
Tuple tuple2 = tuple;
Foo foo = (Foo)this.declarations[0].getValue(internalWorkingMemory,
tuple2.getFactHandle().getObject());
List list = foo.getBarNames();
String string = ((Bar)internalFactHandle.getObject()).getName();
return !(list == null ? false : (string == null ? false :
EvaluatorHelper.contains((Object)list, (Object)string)));
}
public ConditionEvaluator4471f59df9b54235ba1be708b5c480da(Declaration[]
arrdeclaration) {
this.declarations = arrdeclaration;
}
}
{code}