That's a nice one.. We will definitely create a test for that.. if it's not
there..
2011/9/26 Swindells, Thomas <TSwindells(a)nds.com>
I’ve just tried upgrading from Drools 5.3.0-CR1 from the beta and
I’ve
hit a regression.****
** **
JBoss seems to have been down for most of today so I haven’t been able to
raise a Jira for it.****
** **
In our model we have Facts which contain fields of java.lang.class, we then
have a rule which checks that they aren’t null.****
Eg****
Fact { Class<Object> classField}****
** **
Rule “xyz”****
When****
Fact(classField != null)****
Then****
…****
End****
** **
This is giving the following exception****
** **
Caused by: java.lang.ClassCastException:
org.drools.base.field.ObjectFieldImpl cannot be cast to
org.drools.base.field.ClassFieldImpl****
at
org.drools.base.evaluators.EqualityEvaluatorsDefinition$ClassEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1772)
****
at
org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:87)**
**
at
org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:109)***
*
at
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130)****
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451)
****
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:369)
****
at
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134)****
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451)
****
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:379)
****
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:204)****
at
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)****
at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330)****
at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)****
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:882)
****
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180)
****
... 149 more****
** **
Wrapping the classField != null within an eval appears to be a work around.
****
** **
This is in the suspect method:****
*public* *boolean* evaluate(InternalWorkingMemory workingMemory,**
**
*final* InternalReadAccessor extractor,***
*
*final* Object object1, *final* FieldValue
object2) {****
Object value1 = extractor.getValue( workingMemory, object1 );*
***
Object value2 = object2.getValue();****
*if* ( value2 == *null* ) {****
ClassFieldImpl classField = (ClassFieldImpl) object2;****
value2 = classField.resolve( workingMemory );****
}****
*return* *comparator*.equals( value1, value2 );****
}****
** **
I think the if statement just needs an instanceof check as well or some
other way to track the fact that null may be a valid value to be comparing
with!****
** **
** **
Thomas****
------------------------------
**************************************************************************************
This message is confidential and intended only for the addressee. If you
have received this message in error, please immediately notify the
postmaster(a)nds.com and delete it from your system as well as any copies.
The content of e-mails as well as traffic data may be monitored by NDS for
employment and security purposes. To protect the environment please do not
print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18
4EX, United Kingdom. A company registered in England and Wales. Registered
no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users