Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4841

Null BigDecimals converted to String with add operator

    Details

    • Type: Bug
    • Status: Closed
    • Priority: 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
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: