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

executable model doesn't resolve bind variable from another pattern of the same type in method call in LHS for property reactivity

    XMLWordPrintable

Details

    • False
    • None
    • False
    • CR1
    • +
    • Hide
      $ unzip reproducer_method_in_constraint_1b.zip
      $ cd reproducer_method_in_constraint_1b
      $ ./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_1b.zip $ cd reproducer_method_in_constraint_1b $ ./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 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)

    Description

      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 from another pattern of the same type (*1-2) is passed to the method, an infinite loop between "Rule 1" and "Rule 2" does occur in executable model and does not occur in non-executable model.

      (*1) Example rules

      rule "Rule 1"
          when
              $fact1 : Fact1( $id1 : id == 1 )
              Fact2( $id2 : id == 2 )                             // ..... (*1-2) $id2 is bound here
              Fact2( id == 2, convertToIdString($id2) == "id2" )  // ..... (*1-1) $id2 is passed to the method
          then
              System.out.println("***** Action of " + drools.getRule().getName());
      
              modify($fact1) {
                  value = $id2
              }
      end
      
      rule "Rule 2"
          when
              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");
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: