[jboss-jira] [JBoss JIRA] Resolved: (JBRULES-389) Use of "exists" causes a ClassCastException
Edson Tirelli (JIRA)
jira-events at jboss.com
Sat Aug 5 11:10:12 EDT 2006
[ http://jira.jboss.com/jira/browse/JBRULES-389?page=all ]
Edson Tirelli resolved JBRULES-389.
-----------------------------------
Resolution: Done
Problem fixed and commited in 3.0.x branch in revision #5493. Test cases added.
----------
$ svn commit drools-core/src/main/java/org/drools/rule/BoundVariableConstraint.java drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java drools-compiler/src/test/resources/org/drools/integrationtests/test_ExistsWithBindings.drl
Sending drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java
Adding drools-compiler/src/test/resources/org/drools/integrationtests/test_ExistsWithBindings.drl
Sending drools-core/src/main/java/org/drools/rule/BoundVariableConstraint.java
Transmitting file data ...
Committed revision 5493.
----------
Commited in trunk in revision #5494:
----------
$ svn commit drools-core/src/main/java/org/drools/rule/VariableRestriction.java drools-compiler/src/test/resources/org/drools/integrationtests/test_ExistsWithBindings.drl drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java
Sending drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java
Adding drools-compiler/src/test/resources/org/drools/integrationtests/test_ExistsWithBindings.drl
Sending drools-core/src/main/java/org/drools/rule/VariableRestriction.java
Transmitting file data ...
Committed revision 5494.
----------
It was a regression indeed introduced in revision #3951 (don't know in which version it was released):
- return evaluator.evaluate( this.fieldExtractor.getValue( workingMemory.getObject( handle ) ),
- declaration.getValue( workingMemory.getObject( tuple.get( this.declaration ) ) ) );
+ return evaluator.evaluate( this.fieldExtractor.getValue( handle.getObject() ),
+ declaration.getValue( tuple.get( this.column ).getObject() ) );
Look at
tuple.get( this.column )
instead of
tuple.get( this.declaration )
Let me know if you find any other problem.
> Use of "exists" causes a ClassCastException
> -------------------------------------------
>
> Key: JBRULES-389
> URL: http://jira.jboss.com/jira/browse/JBRULES-389
> Project: JBoss Rules
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: Reteoo
> Affects Versions: 3.0.3
> Reporter: Edson Tirelli
> Assigned To: Edson Tirelli
> Fix For: 3.0.4
>
>
> 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)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list