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

Evaluation of the RHS in a rule with multiple matches using noloop and update gets cut short

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 6.0.1.Final
    • None
    • None
    • None

      If you have a rule with both noloop and update where there are multiple matches on the LHS, the RHS only runs for first match instead of running for all matches. The following example shows the problem:

              @Test
              public void testMultipleNoLoop1() {
                  String str =
                          "import org.drools.compiler.Person\n" +
                          "rule R no-loop\n" +
                          "when\n" +
                          "  String()\n" +
                          "  $p : Person( $age : age )\n" +
                          "then\n" +
                          "    modify($p) { setAge( $age + 1 ) }\n" +
                          "end\n";
           
                  KnowledgeBase kbase = loadKnowledgeBaseFromString(str);
                  StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
           
                  Person mario = new Person("Mario", 38);
           
                  ksession.insert("a");
                  ksession.insert("b");
                  ksession.insert(mario);
                  ksession.fireAllRules();
           
                  assertEquals(40, mario.getAge());
              }
      

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

              Created:
              Updated:
              Resolved: