[
https://issues.jboss.org/browse/JBRULES-3604?page=com.atlassian.jira.plug...
]
RH Bugzilla Integration commented on JBRULES-3604:
--------------------------------------------------
Mario Fusco <mfusco(a)redhat.com> changed the Status of [bug
851469|https://bugzilla.redhat.com/show_bug.cgi?id=851469] from NEW to MODIFIED
Updating a fact causes NPE with extends
---------------------------------------
Key: JBRULES-3604
URL:
https://issues.jboss.org/browse/JBRULES-3604
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: drools-core (expert)
Affects Versions: 5.4.0.Final
Reporter: Bobby Graham
Assignee: Mark Proctor
Attachments: ExternalUpdateInheritanceTest.java, inheritance.drl
Problem: When there are two rules (A and B) such that B extends A and both A and B
reference the same fact in their conditions, calling update on that fact after calling
fireAllRules causes a NPE.
DRL:
{code}
package inheritance
import org.drools.Address
rule "Parent"
enabled false
when
Address(suburb == "xyz")
then
end
rule "Child" extends "Parent"
when
$addy:Address(street == "123 some street")
then
System.out.println($addy);
end
{code}
Test:
{code}
package org.drools.testframework;
import org.drools.Address;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.Resource;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.rule.FactHandle;
import org.junit.Test;
public class ExternalUpdateInheritanceTest {
@Test
public void testExternalInheritanceFactUpdates() {
KnowledgeBase knowledgeBase = null;
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
Resource newClassPathResource =
ResourceFactory.newClassPathResource("org/drools/lang/inheritance.drl");
builder.add(newClassPathResource, ResourceType.DRL);
if (builder.hasErrors()) {
throw new RuntimeException(builder.getErrors().toString());
}
knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages());
StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession();
Address address = new Address();
address.setSuburb("xyz");
FactHandle addressHandle = ksession.insert(address);
int rulesFired = ksession.fireAllRules();
address.setStreet("123 some street");
ksession.update(addressHandle, address);
System.out.println(rulesFired);
}
}
{code}
Stack Trace:
java.lang.NullPointerException
at org.drools.common.DefaultAgenda.createActivation(DefaultAgenda.java:572)
at org.drools.reteoo.RuleTerminalNode.modifyLeftTuple(RuleTerminalNode.java:297)
at org.drools.reteoo.LeftTupleSource.doModifyLeftTuple(LeftTupleSource.java:297)
at
org.drools.reteoo.AbstractTerminalNode.modifyLeftTuple(AbstractTerminalNode.java:104)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateModifyLeftTuple(SingleLeftTupleSinkAdapter.java:205)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateModifyObject(SingleLeftTupleSinkAdapter.java:235)
at org.drools.reteoo.LeftInputAdapterNode.modifyObject(LeftInputAdapterNode.java:170)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateModifyObject(SingleObjectSinkAdapter.java:68)
at org.drools.reteoo.AlphaNode.modifyObject(AlphaNode.java:157)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:507)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:421)
at org.drools.reteoo.ObjectTypeNode.modifyObject(ObjectTypeNode.java:314)
at org.drools.reteoo.EntryPointNode.modifyObject(EntryPointNode.java:265)
at org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:474)
at org.drools.common.AbstractWorkingMemory.update(AbstractWorkingMemory.java:960)
at org.drools.common.AbstractWorkingMemory.update(AbstractWorkingMemory.java:933)
at
org.drools.impl.StatefulKnowledgeSessionImpl.update(StatefulKnowledgeSessionImpl.java:284)
at
org.drools.testframework.ExternalUpdateInheritanceTest.testExternalInheritanceFactUpdates(ExternalUpdateInheritanceTest.java:44)
--
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