jdk/src/share/classes/java/util/Map.java
changeset 18280 6c3c0ff49eb5
parent 16867 76499721c6c1
child 18532 0bbca0914946
--- a/jdk/src/share/classes/java/util/Map.java	Tue Jun 18 14:11:45 2013 -0700
+++ b/jdk/src/share/classes/java/util/Map.java	Tue Jun 18 16:03:10 2013 -0700
@@ -545,6 +545,7 @@
                 k = entry.getKey();
                 v = entry.getValue();
             } catch(IllegalStateException ise) {
+                // this usually means the entry is no longer in the map.
                 throw new ConcurrentModificationException(ise);
             }
             action.accept(k, v);
@@ -599,9 +600,19 @@
                 k = entry.getKey();
                 v = entry.getValue();
             } catch(IllegalStateException ise) {
+                // this usually means the entry is no longer in the map.
                 throw new ConcurrentModificationException(ise);
             }
-            entry.setValue(function.apply(k, v));
+
+            // ise thrown from function is not a cme.
+            v = function.apply(k, v);
+
+            try {
+                entry.setValue(v);
+            } catch(IllegalStateException ise) {
+                // this usually means the entry is no longer in the map.
+                throw new ConcurrentModificationException(ise);
+            }
         }
     }