Bug 784360 - java.util.ConcurrentModificationException: at java.util.HashMap$HashIterator.nextEntry(HashMap.java) at org.mozilla.gecko.DoorHangerPopup.onTabChanged(DoorHangerPopup.java). r=wesj a=lsblakk
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Wed, 29 Aug 2012 16:42:15 -0700
changeset 113428 96a2697cec57636b8c135876b7afeee8da1312d6
parent 113427 e94f1c37f8edc2ccfb66e8a508cc3358b80865b5
child 113429 804bde49e276335547aee0a22be583849e961d93
push id2349
push usermleibovic@mozilla.com
push dateWed, 17 Oct 2012 17:11:43 +0000
treeherdermozilla-aurora@96a2697cec57 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj, lsblakk
bugs784360
milestone18.0a2
Bug 784360 - java.util.ConcurrentModificationException: at java.util.HashMap$HashIterator.nextEntry(HashMap.java) at org.mozilla.gecko.DoorHangerPopup.onTabChanged(DoorHangerPopup.java). r=wesj a=lsblakk
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());