--- old/src/java.base/share/classes/java/util/HashMap.java 2018-12-17 07:25:13.770953982 +0100 +++ new/src/java.base/share/classes/java/util/HashMap.java 2018-12-17 07:25:13.331952967 +0100 @@ -501,9 +501,14 @@ (int)ft : MAXIMUM_CAPACITY); if (t > threshold) threshold = tableSizeFor(t); + } else { + // Because of linked-list buckets constraints, we cannot + // expand all at once, but can reduce total resize + // effort by repeated doubling now vs later + while (table.length < MAXIMUM_CAPACITY && s > threshold) { + resize(); + } } - else if (s > threshold) - resize(); for (Map.Entry e : m.entrySet()) { K key = e.getKey(); V value = e.getValue();