Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Duplicate
-
None
-
None
Description
AbstractHashedMap(int initialCapacity, float loadFactor) throws IllegalArgumentException when initialized to zero initialCapacity. Although this is the documented behaviour it is quite unexpected as it differs from the java.util.HashMap implementation and provokes absurd exceptions, e.g. in code like this:
List results = criteria.list();
Map resultMap = new HashedMap(results.size());
It would be much safer to silently replace a zero initial capacity by initial capacity 1. Exactly this behaviour is already implemented in calculateNewCapacity(). Only the validation and the javadoc would have to be adapted.