svn commit: r1848336 - /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: r1848336 - /ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java

jleroux@apache.org
Author: jleroux
Date: Thu Dec  6 16:15:54 2018
New Revision: 1848336

URL: http://svn.apache.org/viewvc?rev=1848336&view=rev
Log:
Fixed: ConcurrentModificationException in ShoppingCart.cleanUpShipGroups
(OFBIZ-10696)

There's a for-loop over shipInfo and a call to clear inside this loop which
leads to a ConcurrentModificationException

Thanks: Danny Trunk

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=1848336&r1=1848335&r2=1848336&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 Dec  6 16:15:54 2018
@@ -2239,16 +2239,18 @@ public class ShoppingCart implements Ite
     }
 
     public void cleanUpShipGroups() {
-        for (CartShipInfo csi : this.shipInfo) {
-            Iterator<ShoppingCartItem> si = csi.shipItemInfo.keySet().iterator();
+        Iterator<CartShipInfo> csi = this.shipInfo.iterator();
+        while (csi.hasNext()) {
+            CartShipInfo info = csi.next();
+            Iterator<ShoppingCartItem> si = info.shipItemInfo.keySet().iterator();
             while (si.hasNext()) {
                 ShoppingCartItem item = si.next();
                 if (item.getQuantity().compareTo(BigDecimal.ZERO) == 0) {
                     si.remove();
                 }
             }
-            if (csi.shipItemInfo.size() == 0) {
-                this.shipInfo.remove(csi);
+            if (info.shipItemInfo.size() == 0) {
+                csi.remove();
             }
         }
     }