commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (COLLECTIONS-392) AbstractHashedMap should not throw exception when initialized to zero size
Date Mon, 22 Apr 2013 20:51:17 GMT

     [ https://issues.apache.org/jira/browse/COLLECTIONS-392?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Thomas Neidhart updated COLLECTIONS-392:
----------------------------------------

    Fix Version/s:     (was: 3.2.2)
    
> AbstractHashedMap should not throw exception when initialized to zero size
> --------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-392
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-392
>             Project: Commons Collections
>          Issue Type: Improvement
>          Components: Map
>            Reporter: Bernhard Seebass
>            Priority: Minor
>             Fix For: 4.0
>
>   Original Estimate: 0.25h
>  Remaining Estimate: 0.25h
>
> 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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message