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

Null BigDecimals converted to String with add operator

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.10
    • 2.0-beta-3
    • None

    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

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

            Dates

              Created:
              Updated:
              Resolved: