Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-9975

ShippingEvents.getShipGroupEstimate() method gives untraceable null pointer exception for BigDecimal comparison

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Release Branch 16.11, Trunk
    • 16.11.04
    • order
    • None

    Description

      The compareTo() method of BigDecimal is not null safe due to which in the following code:

              if (BigDecimal.ZERO.compareTo(shippingTotal) < 0 && BigDecimal.ZERO.compareTo(totalAllowance) < 0) {
                  BigDecimal shippingAllowancePercent = storeShipMethod.getBigDecimal("allowancePercent") != null ? storeShipMethod.getBigDecimal("allowancePercent") : BigDecimal.ZERO;
                  totalAllowance = totalAllowance.multiply(shippingAllowancePercent.divide(BigDecimal.valueOf(100)));
                  shippingTotal = shippingTotal.subtract(totalAllowance);
              }
      

      when totalAllowance value is null it throws null pointer exception which may be difficult to trace sometimes.
      Valid null pointer checks should be there before using compareTo() if the variable may have a null value in any of the case.

      Attachments

        1. OFBIZ-9975.patch
          1 kB
          Aditya Sharma

        Activity

          People

            jleroux Jacques Le Roux
            adityasharma Aditya Sharma
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: