str operator using bind variable fails with "java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0"
Issue
When str operator is used with bind variable in constraint like the following:
~~~
when
$fact : Fact( $s: name, $s str[startsWith] "1" )
then
...
~~~
evaluation of the constraint fails with the exception like the following once MVEL constraint jitting takes place(i.e. it's evaluated more than 20 times by default.)
org.drools.mvel.ConstraintEvaluationException: Error evaluating constraint '$s.startsWith("1")' in [Rule "rule_check_startsWith", "rule_str_startsWith_NG" in /path/to/reproducer-startsWith/kjar/target/classes/com/example/reproducer/Sample.drl]
at org.drools.mvel.MVELConstraint.evaluate(MVELConstraint.java:286)
at org.drools.mvel.MVELConstraint.isAllowed(MVELConstraint.java:234)
at org.drools.core.reteoo.AlphaNode.assertObject(AlphaNode.java:134)
at org.drools.core.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:742)
at org.drools.core.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:595)
at org.drools.core.reteoo.ObjectTypeNode.propagateAssert(ObjectTypeNode.java:297)
at org.drools.core.phreak.PropagationEntry$Insert.propagate(PropagationEntry.java:162)
at org.drools.core.phreak.PropagationEntry$Insert.execute(PropagationEntry.java:167)
at org.drools.core.phreak.SynchronizedPropagationList.flush(SynchronizedPropagationList.java:100)
at org.drools.core.phreak.SynchronizedPropagationList.flush(SynchronizedPropagationList.java:95)
at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:853)
at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:816)
at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:808)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1341)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1332)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1316)
at com.example.reproducer.DroolsTest.main(DroolsTest.java:36)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at org.drools.core.base.EvaluatorWrapper.getFactHandle(EvaluatorWrapper.java:260)
at org.drools.core.base.EvaluatorWrapper.loadHandles(EvaluatorWrapper.java:219)
at org.drools.core.rule.constraint.EvaluatorHelper.initOperators(EvaluatorHelper.java:54)
at ConditionEvaluator07e2037787b947faa23bf9d2cd0c8ae7.evaluate(Unknown Source)
at org.drools.mvel.MVELConstraint.evaluate(MVELConstraint.java:284)
This does not happen when using executable model.
Environment
- Red Hat Decision Manager
- 7.13
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.