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

Order of parameters passed to the method called in accumulate function action() is unexpectedly changed in executable model.

    XMLWordPrintable

Details

    • Bug
    • Status: Verified (View Workflow)
    • Major
    • Resolution: Done
    • 7.8.0.GA, 7.8.1.GA, 7.9.0.GA
    • 7.10.1.GA
    • BRE
    • This issue does not occur on releases from RHDM 7.1.0 to 7.7.1 but occurs on releases from RHDM 7.8.0 to 7.9.0.

    • CR1
    • Hide
      1. Extract reproducer.
        $ unzip reproducer_model_compiler_5a.zip
        $ cd reproducer_model_compiler_5a
        
      2. Build and execute the rule.
        $ ./run_mvn    # mvn clean compile exec:exec -DgenerateModel=YES
            :
            :
        ***** start
        ***** A#method(map = {}, bList = [com.example.reproducer.C@18518ccf, com.example.reproducer.C@46f699d5], cList = [com.example.reproducer.A@39dcf4b0, com.example.reproducer.A@71ae31b0], dList = [com.example.reproducer.B@f6c03cb, com.example.reproducer.B@6e4de19b]) called.
        java.lang.RuntimeException: java.lang.ClassCastException: class com.example.reproducer.C cannot be cast to class com.example.reproducer.B (com.example.reproducer.C and com.example.reproducer.B are in unnamed module of loader 'app')
        	at org.drools.core.rule.SingleAccumulate.accumulate(SingleAccumulate.java:105)
        	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.evalStackEntry(RuleNetworkEvaluator.java:239)
        	at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:182)
        	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:1320)
        	at com.example.reproducer.DroolsTest.main(DroolsTest.java:26)
        Caused by: java.lang.ClassCastException: class com.example.reproducer.C cannot be cast to class com.example.reproducer.B (com.example.reproducer.C and com.example.reproducer.B are in unnamed module of loader 'app')
        	at com.example.reproducer.A.method(A.java:27)
        	at com.example.reproducer.Rule_rule5a107918849$Accumulate0.accumulate(Rule_rule5a107918849.java:27)
        	at com.example.reproducer.Rule_rule5a107918849Accumulate0Invoker.accumulate(Rule_rule5a107918849Accumulate0Invoker.java:38)
        	at org.drools.core.rule.SingleAccumulate.accumulate(SingleAccumulate.java:97)
        	... 21 more
            :
            :
        
      Show
      Extract reproducer. $ unzip reproducer_model_compiler_5a.zip $ cd reproducer_model_compiler_5a Build and execute the rule. $ ./run_mvn # mvn clean compile exec:exec -DgenerateModel=YES : : ***** start ***** A#method(map = {}, bList = [com.example.reproducer.C@18518ccf, com.example.reproducer.C@46f699d5], cList = [com.example.reproducer.A@39dcf4b0, com.example.reproducer.A@71ae31b0], dList = [com.example.reproducer.B@f6c03cb, com.example.reproducer.B@6e4de19b]) called. java.lang.RuntimeException: java.lang.ClassCastException: class com.example.reproducer.C cannot be cast to class com.example.reproducer.B (com.example.reproducer.C and com.example.reproducer.B are in unnamed module of loader 'app') at org.drools.core.rule.SingleAccumulate.accumulate(SingleAccumulate.java:105) 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.evalStackEntry(RuleNetworkEvaluator.java:239) at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:182) 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:1320) at com.example.reproducer.DroolsTest.main(DroolsTest.java:26) Caused by: java.lang.ClassCastException: class com.example.reproducer.C cannot be cast to class com.example.reproducer.B (com.example.reproducer.C and com.example.reproducer.B are in unnamed module of loader 'app') at com.example.reproducer.A.method(A.java:27) at com.example.reproducer.Rule_rule5a107918849$Accumulate0.accumulate(Rule_rule5a107918849.java:27) at com.example.reproducer.Rule_rule5a107918849Accumulate0Invoker.accumulate(Rule_rule5a107918849Accumulate0Invoker.java:38) at org.drools.core.rule.SingleAccumulate.accumulate(SingleAccumulate.java:97) ... 21 more : :
    • Release Notes
    • 2021 Week 07-09 (from Feb 15)
    • +

    Description

      Executing a rule like (*1) that uses action() accumulate function in which calls a method like (*1-1) in executable model, the order of parameters passed to the method is unexpectedly changed and the parameters are not passed correctly. For example of the rule (*1-1), $a.method(map, $bList, $cList, $dList) is actually called as $a.method(map, $cList, $aList, $bList).

      (*1)

      package com.example.reproducer
      
      import java.util.List
      import java.util.Set
      import java.util.Map
      import java.util.HashMap
      
      dialect "java"
      
      rule "rule5a"
          when
              $aList : List() from collect( A() )
              $bList : List() from collect( B() )
              $cList : List() from collect( C() )
              $dList : List() from collect( D() )
              $eSet : Set() from accumulate( $a : A() from $aList,
                                             init( Map map = new HashMap(); ),
                                             action( $a.method(map, $bList, $cList, $dList); ),    // ..... (*1-1)
                                             result( map.keySet() ) )
          then
              System.out.println("***** Action of \"rule5a\" -- $aList = " + $aList + ", $bList = " + $bList + ", $cList = " + $cList + ", $dList = " + $dList + ", $eSet = " + $eSet);
      end
      

      Attachments

        Issue Links

          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: