svn commit: r1024553 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1024553 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java

jonesde
Author: jonesde
Date: Wed Oct 20 08:57:01 2010
New Revision: 1024553

URL: http://svn.apache.org/viewvc?rev=1024553&view=rev
Log:
Fixed an occasional NPE, seems to happen when promo items are being added/removed

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=1024553&r1=1024552&r2=1024553&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java Wed Oct 20 08:57:01 2010
@@ -551,7 +551,6 @@ public class ShoppingCartServices {
             if (UtilValidate.isNotEmpty(orderItems)) {
                 int itemIndex = 0;
                 for (GenericValue item : orderItems) {
-
                     List<GenericValue> orderItemAdjustments = orh.getOrderItemAdjustments(item);
                     // set the item's ship group info
                     List<GenericValue> shipGroupAssocs = orh.getOrderItemShipGroupAssocs(item);
@@ -574,11 +573,16 @@ public class ShoppingCartServices {
 
                         List<GenericValue> shipGroupItemAdjustments = EntityUtil.filterByAnd(orderItemAdjustments, UtilMisc.toMap("shipGroupSeqId", cartShipGroupIndexStr));
                         ShoppingCart.CartShipInfo csi = cart.getShipInfo(cartShipGroupIndex);
-                        List itemTaxAdj = csi.getShipItemInfo(cart.findCartItem(itemIndex)).itemTaxAdj;
-                        for(GenericValue shipGroupItemAdjustment : shipGroupItemAdjustments) {
-                            if ("SALES_TAX".equals(shipGroupItemAdjustment.get("orderAdjustmentTypeId"))) {
-                                itemTaxAdj.add(shipGroupItemAdjustment);
-                                continue;
+                        ShoppingCartItem cartItem = cart.findCartItem(itemIndex);
+                        if (cartItem == null) {
+                            Debug.logWarning("In loadCartFromOrder could not find cart item for itemIndex=" + itemIndex + ", for orderId=" + orderId, module);
+                        } else {
+                            List itemTaxAdj = csi.getShipItemInfo(cartItem).itemTaxAdj;
+                            for(GenericValue shipGroupItemAdjustment : shipGroupItemAdjustments) {
+                                if ("SALES_TAX".equals(shipGroupItemAdjustment.get("orderAdjustmentTypeId"))) {
+                                    itemTaxAdj.add(shipGroupItemAdjustment);
+                                    continue;
+                                }
                             }
                         }
                     }