Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-837

Collect keyword matches two conflicting rules

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 4.0.0.MR2
    • 3.1-m1
    • None
    • None

    Description

      If you have two rules:

      rule "A"
      when
      $a : ArrayList( size:size == 2 ) from collect (Car())
      then
      System.out.println("A: size = " + size);
      end

      rule "B"
      when
      $b : ArrayList( size:size == 3 ) from collect (Car())
      then
      System.out.println("B: size = " + size);
      end

      And you put two Cars in working memory, both A and B will be fired. Since there are two cars in working memory, only rule A should be fired.

      If you change the order of the rules, or make rule A match size == 3 and rule B match size == 2, no rules will be fired instead.

      The only workaround found is to add some criteria for the Car, in ONE of the rules. If rule A for example is:

      rule "A"
      when
      $a : ArrayList( size:size == 2 ) from collect (Car(color == "RED"))
      then
      System.out.println("A: size = " + size);
      end

      Then only rule A will be fired. If the same criteria is also added in rule B, both rules will be fired again.

      Attachments

        Activity

          People

            etirelli@redhat.com Edson Tirelli
            viktornordling Viktor Nordling (Inactive)
            Archiver:
            rhn-support-ceverson Clark Everson

            Dates

              Created:
              Updated:
              Resolved:
              Archived:

              PagerDuty