Uploaded image for project: 'Red Hat Decision Manager'
  1. Red Hat Decision Manager
  2. RHDM-1556

NullPointerException at ConstraintEvaluator.findPatternAndRequiredDeclaration() in accumulate with exec-model

    XMLWordPrintable

Details

    • Bug
    • Status: Verified (View Workflow)
    • Major
    • Resolution: Done
    • 7.9.0.GA
    • 7.10.1.GA
    • BRE
    • CR1
    • 1
    • Release Notes
    • 2020 Week 52-03 (from Dec 21), 2021 Week 04-06 (from Jan 25), 2021 Week 07-09 (from Feb 15)
    • +

    Description

      With exec-model, a rule like this:

      when
          Number(  ) from accumulate (
            FactA( $valueA : value )
            and
            FactB( $valueB : value, eval($valueB.compareTo($valueA) <= 0) )
            ;max($valueB.intValue())
          )
      then
      

      generates the following PATTERN_DSL:

              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));
      

      It misses bind() for var_$valueB. It results in NPE during kbase build.

      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)
      

      ====
      Even this rule causes the issue. So the key factor is the method invocation $valueB.intValue()

      when
          Number(  ) from accumulate (
            FactB( $valueB : value, $valueB > 0 )
            ;max($valueB.intValue())
          )
      then

      Attachments

        Issue Links

          Activity

            People

              rhn-support-tkobayas Toshiya Kobayashi
              rhn-support-anijhawa1 Amit Nijhawan (Inactive)
              Daniel Rosa Daniel Rosa
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: