]
Edson Tirelli closed JBRULES-1388.
----------------------------------
Fix Version/s: 4.0.5
5.0.0-M1
Resolution: Duplicate Issue
Fixed in JBRULES-1389.
Eval error when using multiple declarations
-------------------------------------------
Key: JBRULES-1388
URL:
http://jira.jboss.com/jira/browse/JBRULES-1388
Project: JBoss Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Affects Versions: 4.0.3
Reporter: Hao Chen
Assigned To: Edson Tirelli
Fix For: 4.0.5, 5.0.0-M1
Just started testing Drools 4.0.3, and found rules like the following will cause
ClassCastException when invoked
when
t1 : T1()
t2 : T2()
eval(t2.f1>0)
then
...
end
Looked into the source code and found that: in JavaEvalBuilder.java
final Declaration[] declarations = new Declaration[usedIdentifiers[0].size()];
for ( int i = 0, size = usedIdentifiers[0].size(); i < size; i++ ) {
declarations[i] = context.getDeclarationResolver().getDeclaration( (String)
usedIdentifiers[0].get( i ) );
}
This only retrieves the declarations used in the eval, which in the example include only
t2. So the Drools generated code for the eval is like:
...
T2 t2 = (T2) declarations[0].getValue( (org.drools.common.InternalWorkingMemory)
workingMemory, ( (org.drools.common.InternalFactHandle) tuple.get( declarations[0] )
).getObject() );
...
which cause ClassCastException at runtime because the declarations[0] passed in is
actually t1.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: