Improved: Fix some bugs Spotbugs reports (OFBIZ-12386)

Fixes possible null dereferencings

Follows a comment saying
// first check and see if we are already there; if so, just return success
This commit is contained in:
Jacques Le Roux
2021-11-29 10:09:21 +01:00
parent 4ac3da1082
commit da4b0431ff
2 changed files with 9 additions and 3 deletions
@@ -532,7 +532,10 @@ public class BOMServices {
if (orderShipment != null && !orderReadHelpers.containsKey(orderShipment.getString("orderId"))) {
orderReadHelpers.put(orderShipment.getString("orderId"), new OrderReadHelper(delegator, orderShipment.getString("orderId")));
}
OrderReadHelper orderReadHelper = (OrderReadHelper) orderReadHelpers.get(orderShipment.getString("orderId"));
OrderReadHelper orderReadHelper = null;
if (orderShipment != null) {
orderReadHelper = (OrderReadHelper) orderReadHelpers.get(orderShipment.getString("orderId"));
}
if (orderReadHelper != null) {
Map<String, Object> orderShipmentReadMap = UtilMisc.toMap("orderShipment", orderShipment, "orderReadHelper", orderReadHelper);
String partyId = (orderReadHelper.getPlacingParty() != null ? orderReadHelper.getPlacingParty().getString("partyId") : null);
@@ -1260,7 +1260,10 @@ public class OrderServices {
}
GenericValue orderItemShipGroup = orderItemShipGroupAssoc.getRelatedOne("OrderItemShipGroup", false);
String shipGroupFacilityId = orderItemShipGroup.getString("facilityId");
String itemStatus = orderItem.getString("statusId");
String itemStatus = null;
if (orderItem != null) {
itemStatus = orderItem.getString("statusId");
}
if ("ITEM_REJECTED".equals(itemStatus) || "ITEM_CANCELLED".equals(itemStatus) || "ITEM_COMPLETED".equals(itemStatus)) {
Debug.logInfo("Order item [" + orderItem.getString("orderId") + " / " + orderItem.getString("orderItemSeqId") + "] is not "
+ "in a proper status for reservation", MODULE);
@@ -2610,7 +2613,7 @@ public class OrderServices {
// first check and see if we are already there; if so, just return success
GenericValue testValue = EntityQuery.use(delegator).from("OrderRole").where(fields).queryOne();
if (testValue != null) {
ServiceUtil.returnSuccess();
return ServiceUtil.returnSuccess();
} else {
GenericValue value = delegator.makeValue("OrderRole", fields);
delegator.create(value);