ofbiz-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aditya Sharma (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (OFBIZ-9975) ShippingEvents.getShipGroupEstimate() method gives untraceable null pointer exception for BigDecimal comparison
Date Fri, 10 Nov 2017 13:30:01 GMT

     [ https://issues.apache.org/jira/browse/OFBIZ-9975?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Aditya Sharma updated OFBIZ-9975:
---------------------------------
    Attachment: OFBIZ-9975.patch

Solution:
Added UtilValidate.isNotEmpty() check before comparing using compareTo method.

> ShippingEvents.getShipGroupEstimate() method gives untraceable null pointer exception
for BigDecimal comparison
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-9975
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-9975
>             Project: OFBiz
>          Issue Type: Bug
>          Components: order
>    Affects Versions: Trunk, Release Branch 16.11
>            Reporter: Aditya Sharma
>            Assignee: Aditya Sharma
>         Attachments: OFBIZ-9975.patch
>
>
> The compareTo() method of BigDecimal is not null safe due to which in the following code:
> {code:java}
>         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);
>         }
> {code}
> 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.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message