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

Incorrect parameter is passed to accumulate functions in executable model.

    XMLWordPrintable

Details

    • Bug
    • Status: Verified (View Workflow)
    • Major
    • Resolution: Done
    • 7.1.0.GA, 7.9.0.GA
    • 7.10.1.GA
    • BRE
    • This issue occurs on releases from RHDM 7.1.0 to 7.9.1.

    • CR1
    • Hide
      1. Extract reproducer.
        $ unzip reproducer_model_compiler_17a.zip
        $ cd reproducer_model_compiler_17a
        
      2. Build and execute the rule.
        $ ./run_mvn    # mvn clean compile exec:exec -DgenerateModel=YES
            :
            :
        ***** start
        java.lang.RuntimeException: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer (java.lang.String and java.lang.Integer are in module java.base of loader 'bootstrap')
        	at org.drools.core.rule.MultiAccumulate.accumulate(MultiAccumulate.java:114)
        	at org.drools.core.phreak.PhreakAccumulateNode.addMatch(PhreakAccumulateNode.java:707)
        	at org.drools.core.phreak.PhreakAccumulateNode.doLeftInserts(PhreakAccumulateNode.java:168)
        	at org.drools.core.phreak.PhreakAccumulateNode.doNode(PhreakAccumulateNode.java:89)
        	at org.drools.core.phreak.RuleNetworkEvaluator.switchOnDoBetaNode(RuleNetworkEvaluator.java:583)
        	at org.drools.core.phreak.RuleNetworkEvaluator.evalBetaNode(RuleNetworkEvaluator.java:554)
        	at org.drools.core.phreak.RuleNetworkEvaluator.evalNode(RuleNetworkEvaluator.java:381)
        	at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:341)
        	at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:177)
        	at org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:135)
        	at org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:213)
        	at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:88)
        	at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:33)
        	at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43)
        	at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1111)
        	at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:1058)
        	at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1050)
        	at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1345)
        	at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1336)
        	at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1324)
        	at com.example.reproducer.DroolsTest.main(DroolsTest.java:21)
        Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer (java.lang.String and java.lang.Integer are in module java.base of loader 'bootstrap')
        	at org.drools.core.base.accumulators.IntegerSumAccumulateFunction.accumulate(IntegerSumAccumulateFunction.java:55)
        	at org.drools.core.base.accumulators.IntegerSumAccumulateFunction.accumulate(IntegerSumAccumulateFunction.java:25)
        	at org.drools.modelcompiler.constraints.LambdaAccumulator.accumulate(LambdaAccumulator.java:90)
        	at org.drools.core.rule.MultiAccumulate.accumulate(MultiAccumulate.java:105)
        	... 20 more
            :
            :
        
      Show
      Extract reproducer. $ unzip reproducer_model_compiler_17a.zip $ cd reproducer_model_compiler_17a Build and execute the rule. $ ./run_mvn # mvn clean compile exec:exec -DgenerateModel=YES : : ***** start java.lang.RuntimeException: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer (java.lang.String and java.lang.Integer are in module java.base of loader 'bootstrap') at org.drools.core.rule.MultiAccumulate.accumulate(MultiAccumulate.java:114) at org.drools.core.phreak.PhreakAccumulateNode.addMatch(PhreakAccumulateNode.java:707) at org.drools.core.phreak.PhreakAccumulateNode.doLeftInserts(PhreakAccumulateNode.java:168) at org.drools.core.phreak.PhreakAccumulateNode.doNode(PhreakAccumulateNode.java:89) at org.drools.core.phreak.RuleNetworkEvaluator.switchOnDoBetaNode(RuleNetworkEvaluator.java:583) at org.drools.core.phreak.RuleNetworkEvaluator.evalBetaNode(RuleNetworkEvaluator.java:554) at org.drools.core.phreak.RuleNetworkEvaluator.evalNode(RuleNetworkEvaluator.java:381) at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:341) at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:177) at org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:135) at org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:213) at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:88) at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:33) at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43) at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1111) at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:1058) at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1050) at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1345) at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1336) at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1324) at com.example.reproducer.DroolsTest.main(DroolsTest.java:21) Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer (java.lang.String and java.lang.Integer are in module java.base of loader 'bootstrap') at org.drools.core.base.accumulators.IntegerSumAccumulateFunction.accumulate(IntegerSumAccumulateFunction.java:55) at org.drools.core.base.accumulators.IntegerSumAccumulateFunction.accumulate(IntegerSumAccumulateFunction.java:25) at org.drools.modelcompiler.constraints.LambdaAccumulator.accumulate(LambdaAccumulator.java:90) at org.drools.core.rule.MultiAccumulate.accumulate(MultiAccumulate.java:105) ... 20 more : :
    • Release Notes
    • 2021 Week 07-09 (from Feb 15)
    • +

    Description

      When executing a rule like (*1) that uses accumulate statement with some predefined accumulate functions and uses some field bindings in source-pattern part of the accumulate statement in executable model, not the actually specified parameter but the first bound variable is passed to all the accumulate functions.
      For example, in rule (*1), the first bound variable $name in the constraint part of the Car pattern is passed to sum(), which causes ClassCastException like "Steps to Reproduce" field.
      Actually specified parameters should be passed to corresponding accumulate functions correctly.

      (*1)

      package com.example.reproducer
      
      dialect "java"
      
      rule "rule17a1"
          when
              accumulate ( $car : Car( $name : name, $length : length );
                           $count : count($name),
                           $sum : sum($length),
                           $list : collectList($car) )
          then
              System.out.println("***** Action of rule17a1 -- $count = " + $count + ", $sum = " + $sum + ", $list = " + $list);
      end
      

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            rhn-support-myoshida Masato Yoshida
            Daniel Rosa Daniel Rosa
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: