Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-5961

@watch annotation containing "!*" does not work as expected in executable model.

XMLWordPrintable

    • 2020 Week 52-03 (from Dec 21)
    • Hide
      1. Extract reproducer.
        $ unzip reproducer_model_compiler_9b.zip
        $ cd reproducer_model_compiler_9b
        
      2. Build and execute the rule.
        $ ./run_mvn    # mvn clean compile exec:exec -DgenerateModel=YES
            :
            :
        ***** start
        ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 10000, $point2 = 20000
        ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 30000, $point2 = 20000
        ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 50000, $point2 = 20000
        ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 70000, $point2 = 20000
        ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 90000, $point2 = 20000
        ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 110000, $point2 = 20000
        ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 130000, $point2 = 20000
        ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 150000, $point2 = 20000
        ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 170000, $point2 = 20000
        ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 190000, $point2 = 20000
        ***** end
            :
            :
        

      Expected behavior: the rule is executed only once.

      Actual behavior: the rule is executed repeatedly.

      Show
      Extract reproducer. $ unzip reproducer_model_compiler_9b.zip $ cd reproducer_model_compiler_9b Build and execute the rule. $ ./run_mvn # mvn clean compile exec:exec -DgenerateModel=YES : : ***** start ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 10000, $point2 = 20000 ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 30000, $point2 = 20000 ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 50000, $point2 = 20000 ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 70000, $point2 = 20000 ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 90000, $point2 = 20000 ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 110000, $point2 = 20000 ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 130000, $point2 = 20000 ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 150000, $point2 = 20000 ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 170000, $point2 = 20000 ***** Action of "rule9b3" -- $fact = com.example.reproducer.Fact@14f5da2c, $point1 = 190000, $point2 = 20000 ***** end : : Expected behavior: the rule is executed only once. Actual behavior: the rule is executed repeatedly.
    • Undefined
    • NEW
    • NEW
    • ---
    • ---

      Executing a rule like (*1) in executable rule model, the rule is evaluated repeatedly. In this rule, re-evaluation occurs in executable model though @watch(!*) annotation is specified to the pattern like (*1-1). @watch annotation containing !* as below does not work as expected, as well as @watch(!*).

      • @watch(!*, point2)
      • @watch(!*, point1)
      • @watch(point1, !*)

      On the other hand, @watch not containing !*, for example, @watch(!point1, point2) or @watch(!point1, point3), works as expected.

      (*1)

      package com.example.reproducer
      
      dialect "mvel"
      
      rule "rule9b3"
          when
              $fact : Fact( $point1 : point1, $point2 : point2 ) @watch(!*)  // ..... (*1-1)
          then
              System.out.println("***** Action of \"rule9b3\" -- $fact = " + $fact + ", $point1 = " + $point1 + ", $point2 = " + $point2);
              $point1 = $point1.add($point2);
              modify($fact) {
                  point1 = $point1,
                  point3 = $point1
              }
      end
      

              mfusco@redhat.com Mario Fusco
              mfusco@redhat.com Mario Fusco
              Daniel Rosa Daniel Rosa
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: