-
Bug
-
Resolution: Done
-
Minor
-
None
-
None
-
NEW
-
NEW
A rule like this
global java.util.List list;
rule R when
$theFrom : Double() from accumulate(MyPerson( $val : age );
sum( $val ) )
then
list.add($theFrom);
end
works fine but if modified like:
import java.math.BigDecimal;
global java.util.List list;
rule R when
$theFrom : BigDecimal() from accumulate(MyPerson( $val : age );
sum( $val ) )
then
list.add($theFrom);
end
then it breaks at runtime, with ClassCastException.
Suggested correct behavior:
it should either raise a compilation error (if it is a typed function, like sum()) or just fail to match at runtime, as BigDecimal() does not match the result of sum()
full stack trace for reference:
Exception executing consequence for rule "R" in defaultpkg: java.lang.ClassCastException: java.lang.Double cannot be cast to java.math.BigDecimal at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1110) at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:121) at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:74) at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1017) at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1360) at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1298) at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1353) at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1344) at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1325) at org.drools.compiler.integrationtests.AccumulateTest.testCCEAtRuntimeFromAccumulate(AccumulateTest.java:3116) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: java.lang.ClassCastException: java.lang.Double cannot be cast to java.math.BigDecimal at defaultpkg.Rule_R880096074DefaultConsequenceInvokerGenerated.evaluate(Unknown Source) at defaultpkg.Rule_R880096074DefaultConsequenceInvoker.evaluate(Unknown Source) at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1099) ... 32 more
Will submit test case for reproducing the error.
- relates to
-
DROOLS-1175 Accumulates: sum(Long), sum(BigDecimal), sum(Integer) and sum(BigInteger)
- Closed