Bug 784360 - java.util.ConcurrentModificationException: at java.util.HashMap$HashIterator.nextEntry(HashMap.java) at org.mozilla.gecko.DoorHangerPopup.onTabChanged(DoorHangerPopup.java). r=wesj
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Wed, 29 Aug 2012 16:42:15 -0700
changeset 110441 8595e313fc21a8612c18c5c2b03be292dbc2b8f7
parent 110440 967fa8cc6213ac47ea11826e48be1e9d9d2d1ade
child 110442 f4b63574e768ed355231877560fc347c9e9c6285
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewerswesj
bugs784360
milestone19.0a1
Bug 784360 - java.util.ConcurrentModificationException: at java.util.HashMap$HashIterator.nextEntry(HashMap.java) at org.mozilla.gecko.DoorHangerPopup.onTabChanged(DoorHangerPopup.java). r=wesj
mobile/android/base/DoorHangerPopup.java
--- a/mobile/android/base/DoorHangerPopup.java
+++ b/mobile/android/base/DoorHangerPopup.java
@@ -90,20 +90,25 @@ public class DoorHangerPopup extends Pop
         } catch (Exception e) {
             Log.e(LOGTAG, "Exception handling message \"" + event + "\":", e);
         }
     }
 
     public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
         switch(msg) {
             case CLOSED:
-                // Remove any doorhangers for a tab when it's closed
+                // Remove any doorhangers for a tab when it's closed (make
+                // a temporary set to avoid a ConcurrentModificationException)
+                HashSet<DoorHanger> doorHangersToRemove = new HashSet<DoorHanger>();
                 for (DoorHanger dh : mDoorHangers) {
                     if (dh.getTabId() == tab.getId())
-                        removeDoorHanger(dh);
+                        doorHangersToRemove.add(dh);
+                }
+                for (DoorHanger dh : doorHangersToRemove) {
+                    removeDoorHanger(dh);
                 }
                 break;
 
             case LOCATION_CHANGE:
                 // Only remove doorhangers if the popup is hidden or if we're navigating to a new URL
                 if (!isShowing() || !data.equals(tab.getURL()))
                     removeTransientDoorHangers(tab.getId());