[jboss-jira] [JBoss JIRA] (DROOLS-1360) Infinite loop when updating a fact inside a shared subnetwork
Mario Fusco (JIRA)
issues at jboss.org
Tue Nov 15 10:15:01 EST 2016
Mario Fusco created DROOLS-1360:
-----------------------------------
Summary: Infinite loop when updating a fact inside a shared subnetwork
Key: DROOLS-1360
URL: https://issues.jboss.org/browse/DROOLS-1360
Project: Drools
Issue Type: Bug
Components: core engine
Reporter: Mario Fusco
Assignee: Mario Fusco
Priority: Critical
Updating a fact evaluated inside a shared subnetwork may cause an infinite loop as demonstrated by the following unit test:
{code}
@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());
}
{code}
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
More information about the jboss-jira
mailing list