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

Result type of BigDecimal operation with one or more null value operands should not be a String/Boolean-type value.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 7.12.1.GA
    • 7.9.0.GA, 7.11.1.GA
    • BRE
    • This issue was found in RHDM 7.9.0 but it is reproducible on RHDM 7.11.1 as well.

    • False
    • False
    • Release Notes
    • CR1
    • -
    • Hide

      Extract reproducer_bd_calc_1a.zip and run run_mvn_RHDM-7.11.1 script.

      $ unzip reproducer_bd_calc_1a.zip
      $ cd reproducer_bd_calc_1a
      $ ./run_mvn_RHDM-7.11.1          # if you want to run on RHDM 7.9.0, use run_mvn script.
      
      Show
      Extract reproducer_bd_calc_1a.zip and run run_mvn_ RHDM-7 .11.1 script. $ unzip reproducer_bd_calc_1a.zip $ cd reproducer_bd_calc_1a $ ./run_mvn_RHDM-7.11.1 # if you want to run on RHDM 7.9.0, use run_mvn script.
    • 2021 Week 49-51 (from Dec 6th)

    Description

      The result of BigDecimal-type binary operation when either one or both operands are null becomes a String-type or Boolean-type value.
      For example, when the expressions in RHS of a rule is like (*1) below, the results will be a String-type value or a Boolean-type value `false`.

      (*1) Example rule

      dialect "mvel"
      
      rule "rule1a"
        when
          Calc( $a : a, $b : b )
        then
          System.out.print("***** Action of rule1a: " + $a + " + " + $b);
          BigDecimal $c = $a + $b;                              .......... (*1-1)
          System.out.println(" = " + $c + " (" + $c.getClass().getName() + ")");
      
          System.out.print("***** Action of rule1a: " + $a + " - " + $b);
          BigDecimal $c = $a - $b;                              .......... (*1-2)
          System.out.println(" = " + $c + " (" + $c.getClass().getName() + ")");
      
          System.out.print("***** Action of rule1a: " + $a + " * " + $b);
          BigDecimal $c = $a * $b;                              .......... (*1-3)
          System.out.println(" = " + $c + " (" + $c.getClass().getName() + ")");
      
          System.out.print("***** Action of rule1a: " + $a + " / " + $b);
          BigDecimal $c = $a / $b;                              .......... (*1-4)
          System.out.println(" = " + $c + " (" + $c.getClass().getName() + ")");
      
          System.out.print("***** Action of rule1a: " + $a + " % " + $b);
          BigDecimal $c = $a % $b;                              .......... (*1-5)
          System.out.println(" = " + $c + " (" + $c.getClass().getName() + ")");
      end
      // a and b of Calc are BigDecimal-type properties.
      

      (*2) Java code inserting and calling fireAllRules

      Calc calc1 = new Calc(new BigDecimal("0"), new BigDecimal("1"));
      kSession.insert(calc1);
      Calc calc2 = new Calc(new BigDecimal("0"), null);
      kSession.insert(calc2);
      Calc calc3 = new Calc(null, new BigDecimal("0"));
      kSession.insert(calc3);
      Calc calc4 = new Calc(null, null);
      kSession.insert(calc4);
      
      System.out.println("***** start");
      kSession.fireAllRules();
      System.out.println("***** end");
      

      (*3) Output (each parenthesis shows the result type of the operation)

      ***** start
      ***** Action of rule1a: 0 + 1 = 1 (java.math.BigDecimal)
      ***** Action of rule1a: 0 - 1 = -1 (java.math.BigDecimal)
      ***** Action of rule1a: 0 * 1 = 0 (java.math.BigDecimal)
      ***** Action of rule1a: 0 / 1 = 0 (java.math.BigDecimal)
      ***** Action of rule1a: 0 % 1 = 0 (java.math.BigDecimal)
      ***** Action of rule1a: 0 + null = 0null (java.lang.String)
      ***** Action of rule1a: 0 - null = false (java.lang.Boolean)
      ***** Action of rule1a: 0 * null = false (java.lang.Boolean)
      ***** Action of rule1a: 0 / null = false (java.lang.Boolean)
      ***** Action of rule1a: 0 % null = false (java.lang.Boolean)
      ***** Action of rule1a: null + 0 = null0 (java.lang.String)
      ***** Action of rule1a: null - 0 = false (java.lang.Boolean)
      ***** Action of rule1a: null * 0 = false (java.lang.Boolean)
      ***** Action of rule1a: null / 0 = false (java.lang.Boolean)
      ***** Action of rule1a: null % 0 = false (java.lang.Boolean)
      ***** Action of rule1a: null + null = nullnull (java.lang.String)
      ***** Action of rule1a: null - null = false (java.lang.Boolean)
      ***** Action of rule1a: null * null = false (java.lang.Boolean)
      ***** Action of rule1a: null / null = false (java.lang.Boolean)
      ***** Action of rule1a: null % null = false (java.lang.Boolean)
      ***** end
      

      This issue can be seen when we are not using the executable model but plain drl.
      It is not appropriate the result of these operations are a String or Boolean-type value.

      Attachments

        Issue Links

          Activity

            People

              mfusco@redhat.com Mario Fusco
              rhn-support-myoshida Masato Yoshida
              Daniel Rosa Daniel Rosa
              Daniel Rosa Daniel Rosa
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: