[jboss-jira] [JBoss JIRA] Created: (JBRULES-1428) ClassCastException when comparing BigDecimal fields

Alexandre Gattiker (JIRA) jira-events at lists.jboss.org
Thu Jan 17 03:09:19 EST 2008


ClassCastException when comparing BigDecimal fields
---------------------------------------------------

                 Key: JBRULES-1428
                 URL: http://jira.jboss.com/jira/browse/JBRULES-1428
             Project: JBoss Drools
          Issue Type: Bug
      Security Level: Public (Everyone can see)
    Affects Versions: 4.0.4
            Reporter: Alexandre Gattiker


Works on Drools 4.0.2 but not on Drools 4.0.4.

java.lang.ClassCastException: java.lang.Long
	at org.drools.base.evaluators.BigDecimalFactory$BigDecimalGreaterEvaluator.evaluate(BigDecimalFactory.java:318)
	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:132)
	at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:22)
	at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:153)
	at org.drools.reteoo.Rete.assertObject(Rete.java:175)
	at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
	at org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:909)
	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:881)
	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:682)
	at com.sample.DroolsTest.main(DroolsTest.java:27)


package com.sample
import com.sample.DroolsTest.Message;
rule "rule1"
	when
		Message(value > 0)
	then
end

public class DroolsTest
{

    public static final void main(String[] args)
    {
        try
        {
            RuleBase ruleBase = readRule();
            Message a = new Message();
            a.setValue(new BigDecimal(0));
            WorkingMemory workingMemory = ruleBase.newStatefulSession();
            workingMemory.insert(a);
            workingMemory.fireAllRules();

        }
        catch (Throwable t)
        {
            t.printStackTrace();
        }
    }

    private static RuleBase readRule() throws Exception
    {
        Reader source = new InputStreamReader(DroolsTest.class.getResourceAsStream("/Sample.drl"));
        PackageBuilder builder = new PackageBuilder();
        builder.addPackageFromDrl(source);
        Package pkg = builder.getPackage();
        RuleBase ruleBase = RuleBaseFactory.newRuleBase();
        ruleBase.addPackage(pkg);
        return ruleBase;
    }

    public static class Message
    {
        private BigDecimal value;

        public BigDecimal getValue()
        {
            return this.value;
        }

        public void setValue(BigDecimal value)
        {
            this.value = value;
        }

    }

}


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