[
https://issues.redhat.com/browse/DROOLS-5933?page=com.atlassian.jira.plug...
]
Toshiya Kobayashi updated DROOLS-5933:
--------------------------------------
Description:
With exec-model, a rule like this:
{noformat}
when
Number( ) from accumulate (
FactA( $valueA : value )
and
FactB( $valueB : value, eval($valueB.compareTo($valueA) <= 0) )
;max($valueB.intValue())
)
then
{noformat}
generates the following PATTERN_DSL:
{code:java}
org.drools.model.Rule rule = D.rule("org.drools.mvel.compiler",
"r1").build(D.pattern(var_GENERATED_$pattern_Number$1$),
D.accumulate(D.and(D.pattern(var_GENERATED_$pattern_FactA$2$).bind(var_$valueA,
org.drools.mvel.compiler.P46.LambdaExtractor468EFEB3BE9EA6494C88709DE97051CB.INSTANCE,
D.reactOn("value")),
D.pattern(var_GENERATED_$pattern_FactB$3$).bind(var_6C0A578A2EA3D5A5C82ABB0FA0DE5C71,
org.drools.mvel.compiler.P18.LambdaExtractor18D900ABC004631DF004CDA316CD34FD.INSTANCE,
D.reactOn("value")).expr("A574527869CA97E0B100815026E8E8FA",
var_$valueB,
var_$valueA,
org.drools.mvel.compiler.P3E.LambdaPredicate3E396A3A5FB9CCA4FC041866C27E4A3A.INSTANCE)),
D.accFunction(org.drools.core.base.accumulators.IntegerMaxAccumulateFunction::new,
var_6C0A578A2EA3D5A5C82ABB0FA0DE5C71).as(var_GENERATED_$pattern_Number$1$)),
D.execute(org.drools.mvel.compiler.P97.LambdaConsequence97C360F7B2C85569E6224ABDE862C784.INSTANCE));
{code}
It misses bind() for var_$valueB. It results in NPE during kbase build.
{noformat}
java.lang.NullPointerException
at
org.drools.modelcompiler.constraints.ConstraintEvaluator.findPatternAndRequiredDeclaration(ConstraintEvaluator.java:97)
at
org.drools.modelcompiler.constraints.ConstraintEvaluator.<init>(ConstraintEvaluator.java:67)
at
org.drools.modelcompiler.KiePackagesBuilder.createSingleConstraint(KiePackagesBuilder.java:1064)
at
org.drools.modelcompiler.KiePackagesBuilder.createConstraint(KiePackagesBuilder.java:1049)
at
org.drools.modelcompiler.KiePackagesBuilder.addConstraintsToPattern(KiePackagesBuilder.java:1043)
at org.drools.modelcompiler.KiePackagesBuilder.buildPattern(KiePackagesBuilder.java:730)
at
org.drools.modelcompiler.KiePackagesBuilder.recursivelyAddConditions(KiePackagesBuilder.java:624)
at
org.drools.modelcompiler.KiePackagesBuilder.buildAccumulate(KiePackagesBuilder.java:581)
at
org.drools.modelcompiler.KiePackagesBuilder.conditionToElement(KiePackagesBuilder.java:493)
at
org.drools.modelcompiler.KiePackagesBuilder.addSubConditions(KiePackagesBuilder.java:655)
at org.drools.modelcompiler.KiePackagesBuilder.populateLHS(KiePackagesBuilder.java:449)
at org.drools.modelcompiler.KiePackagesBuilder.compileRule(KiePackagesBuilder.java:249)
at org.drools.modelcompiler.KiePackagesBuilder.build(KiePackagesBuilder.java:220)
at
org.drools.modelcompiler.CanonicalKieModule.createKiePackages(CanonicalKieModule.java:306)
at org.drools.modelcompiler.CanonicalKieModule.lambda$1(CanonicalKieModule.java:213)
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
at
org.drools.modelcompiler.CanonicalKieModule.createKieBase(CanonicalKieModule.java:213)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.createKieBase(KieContainerImpl.java:470)
{noformat}
====
Even this rule causes the issue. So the key factor is the method invocation
$valueB.intValue()
{noformat}
when
Number( ) from accumulate (
FactB( $valueB : value, $valueB > 0 )
;max($valueB.intValue())
)
then
{noformat}
was:
With exec-model, a rule like this:
{noformat}
when
Number( ) from accumulate (
FactA( $valueA : value )
and
FactB( $valueB : value, eval($valueB.compareTo($valueA) <= 0) )
;max($valueB.intValue())
)
then
{noformat}
generates the following PATTERN_DSL:
{code:java}
org.drools.model.Rule rule = D.rule("org.drools.mvel.compiler",
"r1").build(D.pattern(var_GENERATED_$pattern_Number$1$),
D.accumulate(D.and(D.pattern(var_GENERATED_$pattern_FactA$2$).bind(var_$valueA,
org.drools.mvel.compiler.P46.LambdaExtractor468EFEB3BE9EA6494C88709DE97051CB.INSTANCE,
D.reactOn("value")),
D.pattern(var_GENERATED_$pattern_FactB$3$).bind(var_6C0A578A2EA3D5A5C82ABB0FA0DE5C71,
org.drools.mvel.compiler.P18.LambdaExtractor18D900ABC004631DF004CDA316CD34FD.INSTANCE,
D.reactOn("value")).expr("A574527869CA97E0B100815026E8E8FA",
var_$valueB,
var_$valueA,
org.drools.mvel.compiler.P3E.LambdaPredicate3E396A3A5FB9CCA4FC041866C27E4A3A.INSTANCE)),
D.accFunction(org.drools.core.base.accumulators.IntegerMaxAccumulateFunction::new,
var_6C0A578A2EA3D5A5C82ABB0FA0DE5C71).as(var_GENERATED_$pattern_Number$1$)),
D.execute(org.drools.mvel.compiler.P97.LambdaConsequence97C360F7B2C85569E6224ABDE862C784.INSTANCE));
{code}
It misses bind() for var_$valueB. It results in NPE during kbase build.
{noformat}
java.lang.NullPointerException
at
org.drools.modelcompiler.constraints.ConstraintEvaluator.findPatternAndRequiredDeclaration(ConstraintEvaluator.java:97)
at
org.drools.modelcompiler.constraints.ConstraintEvaluator.<init>(ConstraintEvaluator.java:67)
at
org.drools.modelcompiler.KiePackagesBuilder.createSingleConstraint(KiePackagesBuilder.java:1064)
at
org.drools.modelcompiler.KiePackagesBuilder.createConstraint(KiePackagesBuilder.java:1049)
at
org.drools.modelcompiler.KiePackagesBuilder.addConstraintsToPattern(KiePackagesBuilder.java:1043)
at org.drools.modelcompiler.KiePackagesBuilder.buildPattern(KiePackagesBuilder.java:730)
at
org.drools.modelcompiler.KiePackagesBuilder.recursivelyAddConditions(KiePackagesBuilder.java:624)
at
org.drools.modelcompiler.KiePackagesBuilder.buildAccumulate(KiePackagesBuilder.java:581)
at
org.drools.modelcompiler.KiePackagesBuilder.conditionToElement(KiePackagesBuilder.java:493)
at
org.drools.modelcompiler.KiePackagesBuilder.addSubConditions(KiePackagesBuilder.java:655)
at org.drools.modelcompiler.KiePackagesBuilder.populateLHS(KiePackagesBuilder.java:449)
at org.drools.modelcompiler.KiePackagesBuilder.compileRule(KiePackagesBuilder.java:249)
at org.drools.modelcompiler.KiePackagesBuilder.build(KiePackagesBuilder.java:220)
at
org.drools.modelcompiler.CanonicalKieModule.createKiePackages(CanonicalKieModule.java:306)
at org.drools.modelcompiler.CanonicalKieModule.lambda$1(CanonicalKieModule.java:213)
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
at
org.drools.modelcompiler.CanonicalKieModule.createKieBase(CanonicalKieModule.java:213)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.createKieBase(KieContainerImpl.java:470)
{noformat}
NullPointerException at
ConstraintEvaluator.findPatternAndRequiredDeclaration() in accumulate with exec-model
-------------------------------------------------------------------------------------------------------------
Key: DROOLS-5933
URL:
https://issues.redhat.com/browse/DROOLS-5933
Project: Drools
Issue Type: Bug
Components: executable model
Affects Versions: 7.48.0.Final
Reporter: Toshiya Kobayashi
Assignee: Toshiya Kobayashi
Priority: Major
With exec-model, a rule like this:
{noformat}
when
Number( ) from accumulate (
FactA( $valueA : value )
and
FactB( $valueB : value, eval($valueB.compareTo($valueA) <= 0) )
;max($valueB.intValue())
)
then
{noformat}
generates the following PATTERN_DSL:
{code:java}
org.drools.model.Rule rule = D.rule("org.drools.mvel.compiler",
"r1").build(D.pattern(var_GENERATED_$pattern_Number$1$),
D.accumulate(D.and(D.pattern(var_GENERATED_$pattern_FactA$2$).bind(var_$valueA,
org.drools.mvel.compiler.P46.LambdaExtractor468EFEB3BE9EA6494C88709DE97051CB.INSTANCE,
D.reactOn("value")),
D.pattern(var_GENERATED_$pattern_FactB$3$).bind(var_6C0A578A2EA3D5A5C82ABB0FA0DE5C71,
org.drools.mvel.compiler.P18.LambdaExtractor18D900ABC004631DF004CDA316CD34FD.INSTANCE,
D.reactOn("value")).expr("A574527869CA97E0B100815026E8E8FA",
var_$valueB,
var_$valueA,
org.drools.mvel.compiler.P3E.LambdaPredicate3E396A3A5FB9CCA4FC041866C27E4A3A.INSTANCE)),
D.accFunction(org.drools.core.base.accumulators.IntegerMaxAccumulateFunction::new,
var_6C0A578A2EA3D5A5C82ABB0FA0DE5C71).as(var_GENERATED_$pattern_Number$1$)),
D.execute(org.drools.mvel.compiler.P97.LambdaConsequence97C360F7B2C85569E6224ABDE862C784.INSTANCE));
{code}
It misses bind() for var_$valueB. It results in NPE during kbase build.
{noformat}
java.lang.NullPointerException
at
org.drools.modelcompiler.constraints.ConstraintEvaluator.findPatternAndRequiredDeclaration(ConstraintEvaluator.java:97)
at
org.drools.modelcompiler.constraints.ConstraintEvaluator.<init>(ConstraintEvaluator.java:67)
at
org.drools.modelcompiler.KiePackagesBuilder.createSingleConstraint(KiePackagesBuilder.java:1064)
at
org.drools.modelcompiler.KiePackagesBuilder.createConstraint(KiePackagesBuilder.java:1049)
at
org.drools.modelcompiler.KiePackagesBuilder.addConstraintsToPattern(KiePackagesBuilder.java:1043)
at
org.drools.modelcompiler.KiePackagesBuilder.buildPattern(KiePackagesBuilder.java:730)
at
org.drools.modelcompiler.KiePackagesBuilder.recursivelyAddConditions(KiePackagesBuilder.java:624)
at
org.drools.modelcompiler.KiePackagesBuilder.buildAccumulate(KiePackagesBuilder.java:581)
at
org.drools.modelcompiler.KiePackagesBuilder.conditionToElement(KiePackagesBuilder.java:493)
at
org.drools.modelcompiler.KiePackagesBuilder.addSubConditions(KiePackagesBuilder.java:655)
at org.drools.modelcompiler.KiePackagesBuilder.populateLHS(KiePackagesBuilder.java:449)
at org.drools.modelcompiler.KiePackagesBuilder.compileRule(KiePackagesBuilder.java:249)
at org.drools.modelcompiler.KiePackagesBuilder.build(KiePackagesBuilder.java:220)
at
org.drools.modelcompiler.CanonicalKieModule.createKiePackages(CanonicalKieModule.java:306)
at org.drools.modelcompiler.CanonicalKieModule.lambda$1(CanonicalKieModule.java:213)
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
at
org.drools.modelcompiler.CanonicalKieModule.createKieBase(CanonicalKieModule.java:213)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.createKieBase(KieContainerImpl.java:470)
{noformat}
====
Even this rule causes the issue. So the key factor is the method invocation
$valueB.intValue()
{noformat}
when
Number( ) from accumulate (
FactB( $valueB : value, $valueB > 0 )
;max($valueB.intValue())
)
then
{noformat}
--
This message was sent by Atlassian Jira
(v8.13.1#813001)