svn commit: r1832141 - /ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java

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

svn commit: r1832141 - /ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java

nmalin
Author: nmalin
Date: Thu May 24 07:47:12 2018
New Revision: 1832141

URL: http://svn.apache.org/viewvc?rev=1832141&view=rev
Log:
Fixed: Escape NullPointerException with test ProductPromo.testProductShipCharge
(OFBIZ-10370)
In previous commit r1831783, I excluded this line correction but it necessary to ensure all test pass.
This didn't solve the origin problem, why the worker ShoppingCart.getAdjustmentPromoIndex() parse some non promotion adjustment
but just escape potential null pointer that ProductPromo.testProductShipCharge test have been raised.

Modified:
    ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java

Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java?rev=1832141&r1=1832140&r2=1832141&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java Thu May 24 07:47:12 2018
@@ -2874,11 +2874,14 @@ public class ShoppingCart implements Ite
     }
 
     public int getAdjustmentPromoIndex(String productPromoId) {
+        if (UtilValidate.isEmpty(productPromoId)) {
+            return -1;
+        }
         int index = adjustments.size();
         while (index > 0) {
             index--;
-            if (adjustments.get(index).getString("productPromoId").equals(productPromoId)) {
-                return(index);
+            if (productPromoId.equals(adjustments.get(index).getString("productPromoId"))) {
+                return (index);
             }
         }
         return -1;