From 46f3c54c56742ad3333efd964d31720b2df88869 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Wed, 20 May 2009 04:30:13 +0000 Subject: [PATCH] Refactoring putAll to _putAll so the constructor can call the copying in code without running through a subclass' implementation of putAll. Reported in COLLECTIONS-317 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@776542 13f79535-47bb-0310-9956-ffa450edef68 --- .../collections/map/AbstractHashedMap.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/commons/collections/map/AbstractHashedMap.java b/src/java/org/apache/commons/collections/map/AbstractHashedMap.java index d1e1a61ee..67a756803 100644 --- a/src/java/org/apache/commons/collections/map/AbstractHashedMap.java +++ b/src/java/org/apache/commons/collections/map/AbstractHashedMap.java @@ -161,7 +161,7 @@ public class AbstractHashedMap extends AbstractMap implements IterableMap { */ protected AbstractHashedMap(Map map) { this(Math.max(2 * map.size(), DEFAULT_CAPACITY), DEFAULT_LOAD_FACTOR); - putAll(map); + _putAll(map); } /** @@ -295,6 +295,22 @@ public class AbstractHashedMap extends AbstractMap implements IterableMap { * @throws NullPointerException if the map is null */ public void putAll(Map map) { + _putAll(map); + } + + /** + * Puts all the values from the specified map into this map. + *

+ * This implementation iterates around the specified map and + * uses {@link #put(Object, Object)}. + *

+ * It is private to allow the constructor to still call it + * even when putAll is overriden. + * + * @param map the map to add + * @throws NullPointerException if the map is null + */ + private void _putAll(Map map) { int mapSize = map.size(); if (mapSize == 0) { return;