Groovy
  1. Groovy
  2. GROOVY-4841

Null BigDecimals converted to String with add operator

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.10
    • Fix Version/s: 2.0-beta-3
    • Component/s: None
    • Labels:

      Description

      Using the add operator on null BigDecimal objects concatenates them as Strings

        @Test
        void testNullBigDecimalAddOperator() {
          BigDecimal a = null
          BigDecimal b = null
          assert null == a+b
        }
      
      Assertion failed: 
      
      assert null == a+b
                  |  |||
                  |  ||null
                  |  |nullnull
                  |  null
                  false
      

      I would expect a NullPointer would be thrown as the divide operator behaves.

        @Test(expected=NullPointerException)
        void testNullBigDecimalDivOperator() {
          BigDecimal a = null
          BigDecimal b = null
          assert null == a/b
        }
      
      java.lang.NullPointerException: Cannot invoke method div() on null object
      

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Jochen Theodorou
            Reporter:
            Mike Cantrell
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development