You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Nils Kaiser (JIRA)" <ji...@apache.org> on 2006/12/12 19:11:21 UTC

[jira] Created: (COLLECTIONS-237) MultiValueMap: behavior of entrySet().iterator() is not the expected one

MultiValueMap: behavior of entrySet().iterator() is not the expected one
------------------------------------------------------------------------

                 Key: COLLECTIONS-237
                 URL: http://issues.apache.org/jira/browse/COLLECTIONS-237
             Project: Commons Collections
          Issue Type: Bug
          Components: Map
    Affects Versions: 3.2
            Reporter: Nils Kaiser


The entrySet() method of the MultiValueMap delegates the entrySet() call to the decorated map, which is HashMap by default. The default hashmap iterator is used, which causes the iterator to return one Map.Entry for every key. The value returned for the key is an ArrayList, and not the value of the entry which was put into the map.

The expected behavior would be the iterator to return the whole set of entries in the map, which requires iteration over the different array lists contained in the decorated map.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (COLLECTIONS-237) MultiValueMap: behavior of entrySet().iterator() is not the expected one

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COLLECTIONS-237?page=comments#action_12457899 ] 
            
Henri Yandell commented on COLLECTIONS-237:
-------------------------------------------


Given that we flatten values(), it makes a lot of sense to return a flattened entrySet() and not an unflattened one; however entrySet() returns a Set which to me implies that there should not be a duplicated key,value pair. MultiValueMap doesn't stop the value having dupes so it's entirely possible.

So, that seems that either:

1/ We define entrySet as matching keySet and mark this issue WONTFIX.
2/ We define entrySet as matching values and make sure our Map.Entry classes do not equal each other.
3/ We define entrySet as matching unique key-values pairs - so that:

keySet().size() <= entrySet().size() <= values().size()

Anyone have thoughts on which should be done?

Bear in mind that 2+3 both involve backwards compat issues if people are expecting 1.

> MultiValueMap: behavior of entrySet().iterator() is not the expected one
> ------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-237
>                 URL: http://issues.apache.org/jira/browse/COLLECTIONS-237
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Map
>    Affects Versions: 3.2
>            Reporter: Nils Kaiser
>
> The entrySet() method of the MultiValueMap delegates the entrySet() call to the decorated map, which is HashMap by default. The default hashmap iterator is used, which causes the iterator to return one Map.Entry for every key. The value returned for the key is an ArrayList, and not the value of the entry which was put into the map.
> The expected behavior would be the iterator to return the whole set of entries in the map, which requires iteration over the different array lists contained in the decorated map.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org