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

Forall with empty list constraint combined with or does not fire as expected

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • 7.32.0.Final, 7.33.0.Final, 7.34.0.Final, 7.35.0.Final, 7.36.0.Final, 7.37.0.Final, 7.38.0.Final, 7.39.0.Final, 7.40.0.Final, 7.41.0.Final, 7.42.0.Final, 7.43.0.Final
    • core engine
    • None
    • 2020 Week 40-42 (from Sep 28)
    • Hide

      Run: 
      mvn clean test
      on attached reproducer.

      Show
      Run:  mvn clean test on attached reproducer.
    • Undefined
    • NEW
    • NEW
    • ---
    • ---

      As of Drools 7.32.0.Finalforall patterns with "empty list" constraints combined with other constraints through || will fail to match as expected.

      For example the following rule:

      rule "forall with not equal"
      when forall($p : Pojo(y == 1)
                  Pojo(x.empty || x contains 2, z == 3, this == $p))
      then
      end
      

      will not fire against following facts:

      Pojo{x=[2], y=0, z=0}
      Pojo{x=[], y=1, z=3}
      Pojo{x=[3], y=0, z=3}
      Pojo{x=[2], y=1, z=3}
      

      We suspect a problem with the rewriting of the forall clause. It appears the clause is rewritten as:

      not Pojo(y == 1, (x.empty && !(x contains 2)) || !(z == 3))

      instead of the expected:

      not Pojo(y == 1, (!(x.empty) && !(x contains 2)) || !(z == 3))

      This is working fine when using Drools <= 7.31.0.Final.

              mfusco@redhat.com Mario Fusco
              mcasalino Matteo Casalino (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: