Uploaded image for project: 'JBoss BRMS Platform'
  1. JBoss BRMS Platform
  2. RHBRMS-2695

Infinite loop when updating a fact inside a shared subnetwork

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Blocker Blocker
    • 6.4.0.GA
    • None
    • BRE
    • None
    • Release Notes
    • CR2

      Updating a fact evaluated inside a shared subnetwork may cause an infinite loop as demonstrated by the following unit test:

          @Test(timeout = 10000L)
          public void testUpdateOnSharedSubnetwork() {
              String drl =
                      "import " + AtomicInteger.class.getCanonicalName() + ";\n" +
                      "global java.util.List list;\n" +
                      "rule R1y when\n" +
                      "    AtomicInteger() \n" +
                      "    Number() from accumulate ( AtomicInteger( ) and $s : String( ) ; count($s) )" +
                      "    eval(false)\n" +
                      "then\n" +
                      "end\n" +
                      "\n" +
                      "rule R2 when\n" +
                      "    $i : AtomicInteger( get() < 3 )\n" +
                      "then\n" +
                      "    $i.incrementAndGet();" +
                      "    insert(\"test\" + $i.get());" +
                      "    update($i);" +
                      "end\n" +
                      "\n" +
                      "rule R1x when\n" +
                      "    AtomicInteger() \n" +
                      "    $c : Number() from accumulate ( AtomicInteger( ) and $s : String( ) ; count($s) )\n" +
                      "    eval(true)\n" +
                      "then\n" +
                      "    list.add($c);" +
                      "end\n";
      
              KieSession kieSession = new KieHelper().addContent( drl, ResourceType.DRL )
                                                     .build().newKieSession();
      
              List<Number> list = new ArrayList<Number>();
              kieSession.setGlobal( "list", list );
      
              kieSession.insert( new AtomicInteger( 0 ) );
              kieSession.insert( "test" );
      
              kieSession.fireAllRules();
      
              assertEquals(1, list.size());
              assertEquals(4, list.get(0).intValue());
          }
      

            mfusco@redhat.com Mario Fusco
            rhn-support-alazarot Alessandro Lazarotti
            Archiver:
            rhn-support-ceverson Clark Everson
            Marek Winkler Marek Winkler (Inactive)
            Marek Winkler Marek Winkler (Inactive)

              Created:
              Updated:
              Resolved:
              Archived: