< prev index next >

src/java.base/share/classes/java/util/HashMap.java

Print this page
rev 54324 : Test hashmap.clear concurrent modification

@@ -855,12 +855,12 @@
      * Removes all of the mappings from this map.
      * The map will be empty after this call returns.
      */
     public void clear() {
         Node<K,V>[] tab;
-        modCount++;
         if ((tab = table) != null && size > 0) {
+            modCount++;
             size = 0;
             for (int i = 0; i < tab.length; ++i)
                 tab[i] = null;
         }
     }
< prev index next >