diff --git a/pom.xml b/pom.xml
index 5c4a6d85a..d26330a1b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -148,11 +148,14 @@
Janek Bogucki
- Chuck Burdick
+ Maarten Brak
Dave Bryson
+
+ Chuck Burdick
+
Julien Buret
diff --git a/src/java/org/apache/commons/collections/map/AbstractHashedMap.java b/src/java/org/apache/commons/collections/map/AbstractHashedMap.java
index d1e1a61ee..739548d26 100644
--- a/src/java/org/apache/commons/collections/map/AbstractHashedMap.java
+++ b/src/java/org/apache/commons/collections/map/AbstractHashedMap.java
@@ -123,7 +123,7 @@ public class AbstractHashedMap extends AbstractMap implements IterableMap {
* default load factor.
*
* @param initialCapacity the initial capacity
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
*/
protected AbstractHashedMap(int initialCapacity) {
this(initialCapacity, DEFAULT_LOAD_FACTOR);
@@ -135,13 +135,13 @@ public class AbstractHashedMap extends AbstractMap implements IterableMap {
*
* @param initialCapacity the initial capacity
* @param loadFactor the load factor
- * @throws IllegalArgumentException if the initial capacity is less than one
- * @throws IllegalArgumentException if the load factor is less than or equal to zero
+ * @throws IlleagalArgumentException if the initial capacity is negative
+ * @throws IllegalArgumentException if the load factor is less than or equal to zero
*/
protected AbstractHashedMap(int initialCapacity, float loadFactor) {
super();
- if (initialCapacity < 1) {
- throw new IllegalArgumentException("Initial capacity must be greater than 0");
+ if (initialCapacity < 0) {
+ throw new IllegalArgumentException("Initial capacity must be a non negative number");
}
if (loadFactor <= 0.0f || Float.isNaN(loadFactor)) {
throw new IllegalArgumentException("Load factor must be greater than 0");
diff --git a/src/java/org/apache/commons/collections/map/AbstractLinkedMap.java b/src/java/org/apache/commons/collections/map/AbstractLinkedMap.java
index a5cfbe751..8248727de 100644
--- a/src/java/org/apache/commons/collections/map/AbstractLinkedMap.java
+++ b/src/java/org/apache/commons/collections/map/AbstractLinkedMap.java
@@ -90,7 +90,7 @@ public class AbstractLinkedMap extends AbstractHashedMap implements OrderedMap {
* Constructs a new, empty map with the specified initial capacity.
*
* @param initialCapacity the initial capacity
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
*/
protected AbstractLinkedMap(int initialCapacity) {
super(initialCapacity);
@@ -102,7 +102,7 @@ public class AbstractLinkedMap extends AbstractHashedMap implements OrderedMap {
*
* @param initialCapacity the initial capacity
* @param loadFactor the load factor
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
* @throws IllegalArgumentException if the load factor is less than zero
*/
protected AbstractLinkedMap(int initialCapacity, float loadFactor) {
diff --git a/src/java/org/apache/commons/collections/map/CaseInsensitiveMap.java b/src/java/org/apache/commons/collections/map/CaseInsensitiveMap.java
index 2674349d9..9690cd346 100644
--- a/src/java/org/apache/commons/collections/map/CaseInsensitiveMap.java
+++ b/src/java/org/apache/commons/collections/map/CaseInsensitiveMap.java
@@ -78,7 +78,7 @@ public class CaseInsensitiveMap extends AbstractHashedMap implements Serializabl
* Constructs a new, empty map with the specified initial capacity.
*
* @param initialCapacity the initial capacity
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
*/
public CaseInsensitiveMap(int initialCapacity) {
super(initialCapacity);
@@ -90,7 +90,7 @@ public class CaseInsensitiveMap extends AbstractHashedMap implements Serializabl
*
* @param initialCapacity the initial capacity
* @param loadFactor the load factor
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
* @throws IllegalArgumentException if the load factor is less than zero
*/
public CaseInsensitiveMap(int initialCapacity, float loadFactor) {
diff --git a/src/java/org/apache/commons/collections/map/HashedMap.java b/src/java/org/apache/commons/collections/map/HashedMap.java
index f208b4093..530003344 100644
--- a/src/java/org/apache/commons/collections/map/HashedMap.java
+++ b/src/java/org/apache/commons/collections/map/HashedMap.java
@@ -58,7 +58,7 @@ public class HashedMap
* Constructs a new, empty map with the specified initial capacity.
*
* @param initialCapacity the initial capacity
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
*/
public HashedMap(int initialCapacity) {
super(initialCapacity);
@@ -70,7 +70,7 @@ public class HashedMap
*
* @param initialCapacity the initial capacity
* @param loadFactor the load factor
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
* @throws IllegalArgumentException if the load factor is less than zero
*/
public HashedMap(int initialCapacity, float loadFactor) {
diff --git a/src/java/org/apache/commons/collections/map/IdentityMap.java b/src/java/org/apache/commons/collections/map/IdentityMap.java
index ee1fa3db5..88979f528 100644
--- a/src/java/org/apache/commons/collections/map/IdentityMap.java
+++ b/src/java/org/apache/commons/collections/map/IdentityMap.java
@@ -60,7 +60,7 @@ public class IdentityMap
* Constructs a new, empty map with the specified initial capacity.
*
* @param initialCapacity the initial capacity
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
*/
public IdentityMap(int initialCapacity) {
super(initialCapacity);
@@ -72,7 +72,7 @@ public class IdentityMap
*
* @param initialCapacity the initial capacity
* @param loadFactor the load factor
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
* @throws IllegalArgumentException if the load factor is less than zero
*/
public IdentityMap(int initialCapacity, float loadFactor) {
diff --git a/src/java/org/apache/commons/collections/map/LinkedMap.java b/src/java/org/apache/commons/collections/map/LinkedMap.java
index 682f3dc0c..1b170e7f4 100644
--- a/src/java/org/apache/commons/collections/map/LinkedMap.java
+++ b/src/java/org/apache/commons/collections/map/LinkedMap.java
@@ -79,7 +79,7 @@ public class LinkedMap
* Constructs a new, empty map with the specified initial capacity.
*
* @param initialCapacity the initial capacity
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
*/
public LinkedMap(int initialCapacity) {
super(initialCapacity);
@@ -91,7 +91,7 @@ public class LinkedMap
*
* @param initialCapacity the initial capacity
* @param loadFactor the load factor
- * @throws IllegalArgumentException if the initial capacity is less than one
+ * @throws IllegalArgumentException if the initial capacity is negative
* @throws IllegalArgumentException if the load factor is less than zero
*/
public LinkedMap(int initialCapacity, float loadFactor) {
diff --git a/src/test/org/apache/commons/collections/map/TestCaseInsensitiveMap.java b/src/test/org/apache/commons/collections/map/TestCaseInsensitiveMap.java
index b3f27a5ee..e4eb6bf7f 100644
--- a/src/test/org/apache/commons/collections/map/TestCaseInsensitiveMap.java
+++ b/src/test/org/apache/commons/collections/map/TestCaseInsensitiveMap.java
@@ -117,4 +117,12 @@ public class TestCaseInsensitiveMap extends AbstractTestIterableMap {
writeExternalFormToDisk((java.io.Serializable) map, "/home/phil/jakarta-commons/collections/data/test/CaseInsensitiveMap.fullCollection.version3.obj");
}
*/
+
+ /**
+ * Test for COLLECTIONS-323.
+ */
+ public void testInitialCapacityZero() {
+ final CaseInsensitiveMap map = new CaseInsensitiveMap(0);
+ assertEquals(1, map.data.length);
+ }
}
diff --git a/src/test/org/apache/commons/collections/map/TestHashedMap.java b/src/test/org/apache/commons/collections/map/TestHashedMap.java
index 49d2678ac..8eb7d8152 100644
--- a/src/test/org/apache/commons/collections/map/TestHashedMap.java
+++ b/src/test/org/apache/commons/collections/map/TestHashedMap.java
@@ -75,4 +75,12 @@ public class TestHashedMap extends AbstractTestIterableMap {
// resetFull();
// writeExternalFormToDisk((java.io.Serializable) map, "D:/dev/collections/data/test/HashedMap.fullCollection.version3.obj");
// }
+
+ /**
+ * Test for COLLECTIONS-323.
+ */
+ public void testInitialCapacityZero() {
+ final HashedMap map = new HashedMap(0);
+ assertEquals(1, map.data.length);
+ }
}
diff --git a/src/test/org/apache/commons/collections/map/TestIdentityMap.java b/src/test/org/apache/commons/collections/map/TestIdentityMap.java
index b1e6c4eb2..c668fb046 100644
--- a/src/test/org/apache/commons/collections/map/TestIdentityMap.java
+++ b/src/test/org/apache/commons/collections/map/TestIdentityMap.java
@@ -143,4 +143,12 @@ public class TestIdentityMap extends AbstractTestObject {
// map.put(I2A, I2B);
// writeExternalFormToDisk((java.io.Serializable) map, "D:/dev/collections/data/test/IdentityMap.fullCollection.version3.obj");
// }
+
+ /**
+ * Test for COLLECTIONS-323.
+ */
+ public void testInitialCapacityZero() {
+ final IdentityMap map = new IdentityMap(0);
+ assertEquals(1, map.data.length);
+ }
}
diff --git a/src/test/org/apache/commons/collections/map/TestLinkedMap.java b/src/test/org/apache/commons/collections/map/TestLinkedMap.java
index a1d1c16a1..20fd169a4 100644
--- a/src/test/org/apache/commons/collections/map/TestLinkedMap.java
+++ b/src/test/org/apache/commons/collections/map/TestLinkedMap.java
@@ -272,4 +272,12 @@ public class TestLinkedMap extends AbstractTestOrderedMap {
// resetFull();
// writeExternalFormToDisk((java.io.Serializable) map, "D:/dev/collections/data/test/LinkedMap.fullCollection.version3.obj");
// }
+
+ /**
+ * Test for COLLECTIONS-323.
+ */
+ public void testInitialCapacityZero() {
+ final LinkedMap map = new LinkedMap(0);
+ assertEquals(1, map.data.length);
+ }
}