[jboss-jira] [JBoss JIRA] Created: (JBRULES-805) Array of object not supported by contains

ahmed yehdih (JIRA) jira-events at lists.jboss.org
Wed Apr 18 08:51:30 EDT 2007


Array of object not supported by contains 
------------------------------------------

                 Key: JBRULES-805
                 URL: http://jira.jboss.com/jira/browse/JBRULES-805
             Project: JBoss Rules
          Issue Type: Bug
      Security Level: Public (Everyone can see)
         Environment: linux, java1.4
            Reporter: ahmed yehdih
         Assigned To: Mark Proctor


when the array is an array of object like String we get 
java.lang.ClassCastException
	at org.drools.base.evaluators.ObjectFactory$ObjectContainsEvaluator.evaluate(ObjectFactory.java:386)
	at org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:61)
	at org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:82)
	at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:140)
	at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:317)
	at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:183)
	at org.drools.reteoo.Rete.assertObject(Rete.java:121)
	at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:196)
	at org.drools.reteoo.ReteooWorkingMemory.doAssertObject(ReteooWorkingMemory.java:70)
	at org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemory.java:727)
	at org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemory.java:551)

example: assume we have a class message
class Message{
   String [] mess;
}

rule "test"
when 
   Message(mess contains "HELLO")
then 
..
end 
the reason is the test in the org.drools.base.ValueType class
else if ( clazz.isAssignableFrom( Object[].class ) ) {
            return ValueType.ARRAY_TYPE; the test will be satisfied only for array of java.lang.Object and not for others object
a simple solution is to modify this test in 
else if ( clazz.isArray() && clazz.getComponentType() instanceof Object) {
            return ValueType.ARRAY_TYPE;

-- 
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