You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Bernhard Seebass (Created) (JIRA)" <ji...@apache.org> on 2012/01/26 11:11:41 UTC

[jira] [Created] (COLLECTIONS-392) AbstractHashedMap should not throw exception when initialized to zero size

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


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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (COLLECTIONS-392) AbstractHashedMap should not throw exception when initialized to zero size

Posted by "Gary D. Gregory (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COLLECTIONS-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13196371#comment-13196371 ] 

Gary D. Gregory commented on COLLECTIONS-392:
---------------------------------------------

This looks like a duplicate of [COLLECTIONS-323]. If not, can you test a trunk build please for your specific test case? Better yet, can you provide a unit test patch to show the failure in trunk? Thank you.
                
> 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
>   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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (COLLECTIONS-392) AbstractHashedMap should not throw exception when initialized to zero size

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
     [ 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: 4.0
    
> 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: 3.2.2, 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (COLLECTIONS-392) AbstractHashedMap should not throw exception when initialized to zero size

Posted by "Bernhard Seebass (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COLLECTIONS-392?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bernhard Seebass resolved COLLECTIONS-392.
------------------------------------------

       Resolution: Duplicate
    Fix Version/s: 3.2.2

Yes, it definitely is a duplicate. Sorry and thank you. I hadn't found the original issue as HashedMap was only mentioned in a comment.
                
> 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: 3.2.2
>
>   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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira