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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Trunk, Release Branch 16.11
    • Fix Version/s: 16.11.04
    • Component/s: order
    • Labels:
      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

          Activity

            People

            • Assignee:
              jacques.le.roux Jacques Le Roux
              Reporter:
              aditya.sharma Aditya Sharma
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: