Details
-
Bug
-
Resolution: Done
-
Major
-
3.0.3
-
None
Description
Using exists with later bound variables will cause ClassCastException.
package com.sample
import org.drools.Cheese
import org.drools.Person
global java.util.List results
rule "Exists with Bindings"
when
exists Cheese()
c: Cheese( $type : type );
p: Person( likes == $type );
then
results.add( $type );
end
Results in:
java.lang.ClassCastException: org.drools.reteoo.InitialFactImpl
at org.drools.base.org.drools.Cheese$getType.getValue(Unknown Source)
at org.drools.base.ClassFieldExtractor.getValue(ClassFieldExtractor.java:79)
at org.drools.rule.Declaration.getValue(Declaration.java:156)
at org.drools.rule.BoundVariableConstraint.isAllowed(BoundVariableConstraint.java:82)
at org.drools.common.BetaNodeBinder.isAllowed(BetaNodeBinder.java:63)
at org.drools.reteoo.TupleSource.attemptJoin(TupleSource.java:99)
at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:165)
at org.drools.reteoo.ObjectSource.propagateAssertObject(ObjectSource.java:119)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:158)
at org.drools.reteoo.Rete.assertObject(Rete.java:120)
at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:180)
at org.drools.reteoo.ReteooWorkingMemory.doAssertObject(ReteooWorkingMemory.java:69)
at org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemory.java:538)
at org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemory.java:374)
at org.drools.integrationtests.IntegrationCases.testExistsWithBinding(IntegrationCases.java:2608)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)