[jboss-jira] [JBoss JIRA] (JBRULES-3427) Wrong pattern's offsets calculation with complex LHS conditions
Mario Fusco (JIRA)
jira-events at lists.jboss.org
Fri Mar 16 05:38:47 EDT 2012
[ https://issues.jboss.org/browse/JBRULES-3427?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mario Fusco updated JBRULES-3427:
---------------------------------
Description: When combining AND and OR conditions in a complex LHS, the pattern's offsets is not calculated correctly leading to a NPE when trying to extract the object related with the wrong pattern from a tuple. (was: When combining AND and OR conditions in a complex LHS, the pattern's offsets is not calculated correctly leading to a NPE when trying to extract the object related with the wrong pattern from a tuple.
The following test reproduces the problem:
@Test
public void testPatternOffset() throws Exception {
String str = "package org.drools.test; \n" +
"declare A\n" +
"end\n" +
"declare B\n" +
" field : int\n" +
"end\n" +
"declare C\n" +
" field : int\n" +
"end\n" +
"rule R when\n" +
"( " +
" A( ) or ( A( ) and B( ) ) " +
") and (\n" +
" A( ) or ( B( $bField : field ) and C( field != $bField ) )\n" +
")\n" +
"then\n" +
" System.out.println(\"rule fired\");\n" +
"end\n";
KnowledgeBase kbase = loadKnowledgeBaseFromString( str );
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
FactType typeA = kbase.getFactType( "org.drools.test", "A" );
FactType typeB = kbase.getFactType( "org.drools.test", "B" );
FactType typeC = kbase.getFactType( "org.drools.test", "C" );
Object a = typeA.newInstance();
ksession.insert( a );
Object b = typeB.newInstance();
typeB.set( b, "field", 1 );
ksession.insert( b );
Object c = typeC.newInstance();
typeC.set( c, "field", 1 );
ksession.insert( c );
ksession.fireAllRules();
})
> Wrong pattern's offsets calculation with complex LHS conditions
> ---------------------------------------------------------------
>
> Key: JBRULES-3427
> URL: https://issues.jboss.org/browse/JBRULES-3427
> Project: Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Reporter: Mario Fusco
> Assignee: Mario Fusco
>
> When combining AND and OR conditions in a complex LHS, the pattern's offsets is not calculated correctly leading to a NPE when trying to extract the object related with the wrong pattern from a tuple.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list