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

executable model doesn't resolve bind variable in method call in LHS for property reactivity

XMLWordPrintable

    • False
    • None
    • False
    • Release Notes
    • CR1
    • +
    • +
    • Hide
      $ unzip reproducer_method_in_constraint_1a.zip
      $ cd reproducer_method_in_constraint_1a
      $ ./run_mvn
      === generateModel=NO ===
         :
         :
      ***** start
      ***** Action of Rule 1
      ***** Action of Rule 2
      ***** end
         :
         :
      
      === generateModel=YES ===
         :
         :
      ***** start
      ***** Action of Rule 1
      ***** Action of Rule 2
      ***** Action of Rule 1
      ***** Action of Rule 2
      ***** Action of Rule 1
      ***** Action of Rule 2
      ***** Action of Rule 1
      ***** Action of Rule 2
      ***** Action of Rule 1
      ***** Action of Rule 2
      ***** end
         :
         :
      
      Show
      $ unzip reproducer_method_in_constraint_1a.zip $ cd reproducer_method_in_constraint_1a $ ./run_mvn === generateModel=NO === : : ***** start ***** Action of Rule 1 ***** Action of Rule 2 ***** end : : === generateModel=YES === : : ***** start ***** Action of Rule 1 ***** Action of Rule 2 ***** Action of Rule 1 ***** Action of Rule 2 ***** Action of Rule 1 ***** Action of Rule 2 ***** Action of Rule 1 ***** Action of Rule 2 ***** Action of Rule 1 ***** Action of Rule 2 ***** end : :
    • 2023 Week 12-14 (from Mar 20), 2023 Week 15-17 (from Apr 10), 2023 Week 18-20 (from May 1), 2023 Week 21-23 (from May 22), 2023 Week 24-26 (from Jun 12)

      When we execute rules like (*1) and Java code like (*2) below, more specifically, if the pattern (*1-1) has a method call in its constraint and a bound variable is passed to the method, an infinite loop between "Rule 1" and "Rule 2" occurs only in executable model.

      (*1) Example rules

      rule "Rule 1"
         when
             $fact1 : Fact1( $id1 : id == 1 )
             $fact2 : Fact2( $id2 : id == 2, convertToIdString($id2) == "id2" )    ..... (*1-1)
         then
             System.out.println("***** Action of " + drools.getRule().getName());
      
             modify($fact1) {
                 value = $id2
             }
      end
      
      rule "Rule 2"
         when
             $fact1 : Fact1( $id1 : id == 1, value == 2 )
             $fact2 : Fact2( $id2 : id == 2 )
         then
             System.out.println("***** Action of " + drools.getRule().getName());
      
             modify($fact2) {
                 value = $id1
             }
      end
      

      (*2) Java code

      KieServices kServices = KieServices.Factory.get();
      KieContainer kContainer = kServices.getKieClasspathContainer();
      KieSession kSession = kContainer.newKieSession();
      
      Fact1 fact1 = new Fact1();
      fact1.setId(1);
      fact1.setValue(1);
      kSession.insert(fact1);
      
      Fact2 fact2 = new Fact2();
      fact2.setId(2);
      fact1.setValue(2);
      kSession.insert(fact2);
      
      System.out.println("***** start");
      kSession.fireAllRules(10);
      System.out.println("***** end");
      

              rhn-support-tkobayas Toshiya Kobayashi
              rhn-support-myoshida Masato Yoshida
              Daniel Rosa Daniel Rosa
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: