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 110309 8595e313fc21a8612c18c5c2b03be292dbc2b8f7
parent 110308 967fa8cc6213ac47ea11826e48be1e9d9d2d1ade
child 110310 f4b63574e768ed355231877560fc347c9e9c6285
push id23680
push useremorley@mozilla.com
push dateTue, 16 Oct 2012 08:09:24 +0000
treeherdermozilla-central@8f145599e4bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs784360
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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());