[
https://issues.jboss.org/browse/DROOLS-731?page=com.atlassian.jira.plugin...
]
Mario Fusco commented on DROOLS-731:
------------------------------------
There are actually multiple issues here.
First of all the first one of the 2 rules in your original test case doesn't compile
at all because the line containing the declaration of $FactA is commented out.
Unfortunately that rule instead of raising a compilation failure caused an NPE in the
compiler. I reported this problem here
https://issues.jboss.org/browse/DROOLS-734 and
already fixed.
Note that you didn't find this problem because of a bug in your test case. In fact
there you did:
kfs.write(ruleFile, ruleBytes);
kfs.write(ruleFile, ruleBytes2);
Since you used the same file name for both drls the second one overwrote the first and the
first was never compiled.
This means that in your test case you actually had only 1 rule and you're removing it
with an incremental compilation. That indeed caused the NPE you reported and I fixed it
with this commit:
https://github.com/droolsjbpm/drools/commit/730120030
Nevertheless I'm not closing this ticket because I believe we may have other issues,
but the provided test case is not clear enough to allow me to reproduce them. Please
review your test case based on what I wrote and run it against the fixes I already pushed
on master.
In a catch22 using a NOT constraint in rules shared by multiple
facts
---------------------------------------------------------------------
Key: DROOLS-731
URL:
https://issues.jboss.org/browse/DROOLS-731
Project: Drools
Issue Type: Bug
Components: core engine
Affects Versions: 6.0.1.Final, 6.1.0.Final
Environment: Custom application that completely wraps Drools Fusion written as an
OSGI application hosted on Websphere Liberty profile.
Reporter: Bill Tuminaro
Assignee: Mario Fusco
Attachments: DROOLS-731_DroolsTestCases.zip
I have a reproducer for these related issues.
We have encountered a couple of issues (Exceptions) when using a NOT constraint in rules
that have facts associated with them when we call upgradeToVersion() or kSession.delete().
The catch22 is that one version of the NOT constraint avoids one Exception while causing
another. Reproducing the issue requires 2 rules sharing the same NOT constraint. I have
narrowed the issue(s) down to 2 very simple rules that use the org.drools.compiler.FactA
class.
Here are the 2 rules used:
static final String ruleDrl = "package org.some.test\n" +
"import org.drools.compiler.FactA\n" +
"declare FactA\n" +
"@role(event)" +
"end\n" +
"rule \"R200_0\" when\n" +
" $FactA : FactA ($FactA_field2 : field2 == 111002)\n" +
" not FactA($FactA_field2 == 111002, this after $FactA)\n" + // version A:
using this version causes a NPE when calling ksession.delete()
// " not FactA(field2 == 111002, this after $FactA)\n" + // Version B:
using this version causes the IllegalArgumentException: Cannot remove a sink,
// when the list of
sinks is null on the updateToVersion() call
"then\n" +
"end\n";
static final String ruleDrl2 = "package org.some.test\n" +
"import org.drools.compiler.FactA\n" +
"declare FactA\n" +
"@role(event)" +
"end\n" +
"rule \"R1437_0\" when\n" +
" $FactA : FactA ($FactA_field2 : field2 == 105742)\n" +
" not FactA($FactA_field2 == 105742, this after $FactA)\n" + // version A:
// " not FactA(field2 == 105742, this after $FactA)\n" + // Version B:
"then\n" +
"end\n";
We are hitting the following NPE using the reproducer code attached when we use the NOT
Constraint labeled as 'Version A' in the rule:
java.lang.NullPointerExceptionNullPointerException caught: 2
at org.drools.core.reteoo.NotNode.doDeleteRightTuple(NotNode.java:186)
at org.drools.core.reteoo.NotNode.retractRightTuple(NotNode.java:174)
at org.drools.core.reteoo.ObjectTypeNode.doRetractObject(ObjectTypeNode.java:345)
at org.drools.core.reteoo.ObjectTypeNode.retractObject(ObjectTypeNode.java:337)
at org.drools.core.reteoo.EntryPointNode.retractObject(EntryPointNode.java:379)
at org.drools.core.common.NamedEntryPoint.delete(NamedEntryPoint.java:612)
at
org.drools.core.impl.StatefulKnowledgeSessionImpl.delete(StatefulKnowledgeSessionImpl.java:1467)
at
org.drools.core.impl.StatefulKnowledgeSessionImpl.delete(StatefulKnowledgeSessionImpl.java:1458)
at
org.drools.compiler.integrationTests.RemovingARuleCausesNPE.test(RemovingARuleCausesNPE.java:187)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
We are hitting the following IllegalArgumentException using the reproducer code attached
when we use the NOT Constraint labeled as 'Version B' in the rule:
java.lang.IllegalArgumentException: Cannot remove a sink, when the list of sinks is null
at org.drools.core.reteoo.ObjectSource.removeObjectSink(ObjectSource.java:203)
at org.drools.core.reteoo.ObjectSource.doRemove(ObjectSource.java:242)
at org.drools.core.common.BaseNode.remove(BaseNode.java:122)
at org.drools.core.reteoo.ReteooBuilder.removeNode(ReteooBuilder.java:236)
at org.drools.core.reteoo.ReteooBuilder.removeTerminalNode(ReteooBuilder.java:179)
at org.drools.core.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:153)
at org.drools.core.impl.KnowledgeBaseImpl.removeRule(KnowledgeBaseImpl.java:1535)
at
org.drools.core.impl.KnowledgeBaseImpl.removeObjectsGeneratedFromResource(KnowledgeBaseImpl.java:1768)
at
org.drools.compiler.builder.impl.KnowledgeBuilderImpl.removeObjectsGeneratedFromResource(KnowledgeBuilderImpl.java:2029)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.update(KieContainerImpl.java:171)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.updateToVersion(KieContainerImpl.java:104)
at
org.drools.compiler.integrationTests.RemovingARuleCausesNPE.test(RemovingARuleCausesNPE.java:172)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)