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

        Mike Cantrell created issue -
        Jochen Theodorou made changes -
        Field Original Value New Value
        Fix Version/s 2.0-beta-3 [ 18244 ]
        Labels breaking
        Jochen Theodorou made changes -
        Resolution Fixed [ 1 ]
        Assignee blackdrag blackdrag [ blackdrag ]
        Status Open [ 1 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12733770 ] Default workflow, editable Closed status [ 12745584 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12971316 ] Default workflow, editable Closed status [ 12979091 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development