Uploaded image for project: 'Red Hat Decision Manager'
  1. Red Hat Decision Manager
  2. RHDM-1991

Coercion from Interger literal to BigDecimal bind variable

XMLWordPrintable

    • False
    • None
    • False
    • Hide

      There are two reproducers reproducer_bound_variable_type_1a.zip and example_integer_plus_bigdecimal_2a.zip .

      • reproducer_bound_variable_type_1a
        $ unzip reproducer_bound_variable_type_1a.zip
        $ cd reproducer_bound_variable_type_1a
        $ ./run_mvn
        === generateModel=NO ===
            :
            :
        ***** start
        ***** Action of Rule 1: $fact = com.example.reproducer.Fact{id=fact1, value1=1, value2=2}
        (before assigning to $value1) $value1 = 1 (java.math.BigDecimal)
        ( after assigning to $value1) $value1 = 5 (java.lang.Integer)
        Exception executing consequence for rule "Rule 1" in com.example.reproducer: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.math.BigDecimal (java.lang.Integer and java.math.BigDecimal are in module java.base of loader 'bootstrap')
        	at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
        	at org.drools.core.common.DefaultAgenda.handleException(DefaultAgenda.java:1056)
        	at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:462)
        	at org.drools.core.phreak.RuleExecutor.fireActivation(RuleExecutor.java:402)
        	at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:158)
        	at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:110)
        	at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:33)
        	at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43)
        	at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:869)
        	at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:816)
        	at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:808)
        	at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1341)
        	at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1332)
        	at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1316)
        	at com.example.reproducer.DroolsTest.main(DroolsTest.java:25)
        Caused by: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.math.BigDecimal (java.lang.Integer and java.math.BigDecimal are in module java.base of loader 'bootstrap')
        	at org.mvel2.math.MathProcessor.doOperations(MathProcessor.java:65)
        	at org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:146)
        	at org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:38)
        	at org.mvel2.ast.AssignmentNode.getReducedValueAccelerated(AssignmentNode.java:116)
        	at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
        	at org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:115)
        	at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:111)
        	at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:105)
        	at org.mvel2.MVEL.executeExpression(MVEL.java:946)
        	at org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator.executeExpression(RawMVELEvaluator.java:103)
        	at org.drools.mvel.expr.MvelEvaluator.internalEvaluate(MvelEvaluator.java:131)
        	at org.drools.mvel.expr.MvelEvaluator.evaluate(MvelEvaluator.java:115)
        	at org.drools.mvel.expr.MVELConsequence.evaluate(MVELConsequence.java:94)
        	at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:455)
        	... 12 more
            :
            :
        
        === generateModel=YES ===
            :
            :
        ***** start
        ***** Action of Rule 1: $fact = com.example.reproducer.Fact{id=fact1, value1=1, value2=2}
        (before assigning to $value1) $value1 = 1 (java.math.BigDecimal)
        ( after assigning to $value1) $value1 = 5 (java.math.BigDecimal)
        $total = $value1 + $value2 ==> 7 (java.math.BigDecimal) = 5 (java.math.BigDecimal) + 2 (java.math.BigDecimal)
        ***** end
            :
            :
        

        In non-executable model (generateModel=NO), ClassCastException occurs.

      • example_integer_plus_bigdecimal_2a
        $ unzip example_integer_plus_bigdecimal_2a.zip
        $ cd example_integer_plus_bigdecimal_2a
        $ ./run_mvn
        === generateModel=NO ===
            :
            :
        ***** start
        ***** Action of Rule 2a: $fact = com.example.reproducer.Fact{id=fact1, value1=1, value2=2}
        Exception executing consequence for rule "Rule 2a" in com.example.reproducer: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.math.BigDecimal (java.lang.Integer and java.math.BigDecimal are in module java.base of loader 'bootstrap')
        	at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
        	at org.drools.core.common.DefaultAgenda.handleException(DefaultAgenda.java:1056)
        	at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:462)
        	at org.drools.core.phreak.RuleExecutor.fireActivation(RuleExecutor.java:402)
        	at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:158)
        	at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:110)
        	at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:33)
        	at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43)
        	at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:869)
        	at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:816)
        	at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:808)
        	at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1341)
        	at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1332)
        	at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1316)
        	at com.example.reproducer.DroolsTest.main(DroolsTest.java:25)
        Caused by: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.math.BigDecimal (java.lang.Integer and java.math.BigDecimal are in module java.base of loader 'bootstrap')
        	at org.mvel2.math.MathProcessor.doOperations(MathProcessor.java:65)
        	at org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:146)
        	at org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:38)
        	at org.mvel2.ast.AssignmentNode.getReducedValueAccelerated(AssignmentNode.java:116)
        	at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
        	at org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:115)
        	at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:111)
        	at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:105)
        	at org.mvel2.MVEL.executeExpression(MVEL.java:946)
        	at org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator.executeExpression(RawMVELEvaluator.java:103)
        	at org.drools.mvel.expr.MvelEvaluator.internalEvaluate(MvelEvaluator.java:131)
        	at org.drools.mvel.expr.MvelEvaluator.evaluate(MvelEvaluator.java:115)
        	at org.drools.mvel.expr.MVELConsequence.evaluate(MVELConsequence.java:94)
        	at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:455)
        	... 12 more
            :
            :
        
        === generateModel=YES ===
            :
            :
        ***** start
        ***** Action of Rule 2a: $fact = com.example.reproducer.Fact{id=fact1, value1=1, value2=2}
        $total = $var1 + $var2 ==> 7 (java.math.BigDecimal) = 5 (java.math.BigDecimal) + 2 (java.math.BigDecimal)
        ***** end
            :
            :
        

        In non-executable model (generateModel=NO), ClassCastException occurs.

      Show
      There are two reproducers reproducer_bound_variable_type_1a.zip and example_integer_plus_bigdecimal_2a.zip . reproducer_bound_variable_type_1a $ unzip reproducer_bound_variable_type_1a.zip $ cd reproducer_bound_variable_type_1a $ ./run_mvn === generateModel=NO === : : ***** start ***** Action of Rule 1: $fact = com.example.reproducer.Fact{id=fact1, value1=1, value2=2} (before assigning to $value1) $value1 = 1 (java.math.BigDecimal) ( after assigning to $value1) $value1 = 5 (java.lang.Integer) Exception executing consequence for rule "Rule 1" in com.example.reproducer: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.math.BigDecimal (java.lang.Integer and java.math.BigDecimal are in module java.base of loader 'bootstrap') at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) at org.drools.core.common.DefaultAgenda.handleException(DefaultAgenda.java:1056) at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:462) at org.drools.core.phreak.RuleExecutor.fireActivation(RuleExecutor.java:402) at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:158) at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:110) at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:33) at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43) at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:869) at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:816) at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:808) at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1341) at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1332) at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1316) at com.example.reproducer.DroolsTest.main(DroolsTest.java:25) Caused by: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.math.BigDecimal (java.lang.Integer and java.math.BigDecimal are in module java.base of loader 'bootstrap') at org.mvel2.math.MathProcessor.doOperations(MathProcessor.java:65) at org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:146) at org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:38) at org.mvel2.ast.AssignmentNode.getReducedValueAccelerated(AssignmentNode.java:116) at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85) at org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:115) at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:111) at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:105) at org.mvel2.MVEL.executeExpression(MVEL.java:946) at org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator.executeExpression(RawMVELEvaluator.java:103) at org.drools.mvel.expr.MvelEvaluator.internalEvaluate(MvelEvaluator.java:131) at org.drools.mvel.expr.MvelEvaluator.evaluate(MvelEvaluator.java:115) at org.drools.mvel.expr.MVELConsequence.evaluate(MVELConsequence.java:94) at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:455) ... 12 more : : === generateModel=YES === : : ***** start ***** Action of Rule 1: $fact = com.example.reproducer.Fact{id=fact1, value1=1, value2=2} (before assigning to $value1) $value1 = 1 (java.math.BigDecimal) ( after assigning to $value1) $value1 = 5 (java.math.BigDecimal) $total = $value1 + $value2 ==> 7 (java.math.BigDecimal) = 5 (java.math.BigDecimal) + 2 (java.math.BigDecimal) ***** end : : In non-executable model (generateModel=NO), ClassCastException occurs. example_integer_plus_bigdecimal_2a $ unzip example_integer_plus_bigdecimal_2a.zip $ cd example_integer_plus_bigdecimal_2a $ ./run_mvn === generateModel=NO === : : ***** start ***** Action of Rule 2a: $fact = com.example.reproducer.Fact{id=fact1, value1=1, value2=2} Exception executing consequence for rule "Rule 2a" in com.example.reproducer: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.math.BigDecimal (java.lang.Integer and java.math.BigDecimal are in module java.base of loader 'bootstrap') at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) at org.drools.core.common.DefaultAgenda.handleException(DefaultAgenda.java:1056) at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:462) at org.drools.core.phreak.RuleExecutor.fireActivation(RuleExecutor.java:402) at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:158) at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:110) at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:33) at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43) at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:869) at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:816) at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:808) at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1341) at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1332) at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1316) at com.example.reproducer.DroolsTest.main(DroolsTest.java:25) Caused by: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.math.BigDecimal (java.lang.Integer and java.math.BigDecimal are in module java.base of loader 'bootstrap') at org.mvel2.math.MathProcessor.doOperations(MathProcessor.java:65) at org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:146) at org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:38) at org.mvel2.ast.AssignmentNode.getReducedValueAccelerated(AssignmentNode.java:116) at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85) at org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:115) at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:111) at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:105) at org.mvel2.MVEL.executeExpression(MVEL.java:946) at org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator.executeExpression(RawMVELEvaluator.java:103) at org.drools.mvel.expr.MvelEvaluator.internalEvaluate(MvelEvaluator.java:131) at org.drools.mvel.expr.MvelEvaluator.evaluate(MvelEvaluator.java:115) at org.drools.mvel.expr.MVELConsequence.evaluate(MVELConsequence.java:94) at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:455) ... 12 more : : === generateModel=YES === : : ***** start ***** Action of Rule 2a: $fact = com.example.reproducer.Fact{id=fact1, value1=1, value2=2} $total = $var1 + $var2 ==> 7 (java.math.BigDecimal) = 5 (java.math.BigDecimal) + 2 (java.math.BigDecimal) ***** end : : In non-executable model (generateModel=NO), ClassCastException occurs.
    • 2023 Week 36-38 (from Sep 4)

      Issue Description:

      In non-exec-model,

      Where Fact.value1 and value2 are both BigDecimal,

          when
              $fact : Fact( $value1 : value1,
                            $value2 : value2 )
          then
              $value1 = 5;
              $total = $value1 + $value2;
      

       this rule fails with

      Exception executing consequence for rule "Rule 1" in com.example.reproducer: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.math.BigDecimal (java.lang.Integer and java.math.BigDecimal are in module java.base of loader 'bootstrap')
              at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
              at org.drools.core.common.DefaultAgenda.handleException(DefaultAgenda.java:1056)
              at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:462)
              at org.drools.core.phreak.RuleExecutor.fireActivation(RuleExecutor.java:402)
              at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:158)
              at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:110)
              at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:33)
              at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43)
              at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:869)
              at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:816)
              at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:808)
              at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1341)
              at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1332)
              at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1316)
              at com.example.reproducer.DroolsTest.main(DroolsTest.java:25)
          Caused by: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.math.BigDecimal (java.lang.Integer and java.math.BigDecimal are in module java.base of loader 'bootstrap')    <---------- (*2-4)
              at org.mvel2.math.MathProcessor.doOperations(MathProcessor.java:65)
              at org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:146)
              at org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:38)
              at org.mvel2.ast.AssignmentNode.getReducedValueAccelerated(AssignmentNode.java:116)
              at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
              at org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:115)
              at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:111)
              at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:105)
              at org.mvel2.MVEL.executeExpression(MVEL.java:946)
              at org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator.executeExpression(RawMVELEvaluator.java:103)
              at org.drools.mvel.expr.MvelEvaluator.internalEvaluate(MvelEvaluator.java:131)
              at org.drools.mvel.expr.MvelEvaluator.evaluate(MvelEvaluator.java:115)
              at org.drools.mvel.expr.MVELConsequence.evaluate(MVELConsequence.java:94)
              at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:455)
              ... 12 more
      

      $value1 = 5; makes $value1 as Integer type.

      exec-model has no issue because `5` is coerced to a BigDecimal.

      Acceptance Criteria:

      • Run without an Exception.
      • Likely meet with the exec-model behaviour

              rhn-support-tkobayas Toshiya Kobayashi
              rhn-support-myoshida Masato Yoshida
              Paolo Bizzarri Paolo Bizzarri
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: