You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Bruno P. Kinoshita (Jira)" <ji...@apache.org> on 2020/01/12 00:29:00 UTC

[jira] [Commented] (COLLECTIONS-732) Got an UnsupportedOperationException when using MultiValuedMap.MapIterator().setValue()

    [ https://issues.apache.org/jira/browse/COLLECTIONS-732?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17013624#comment-17013624 ] 

Bruno P. Kinoshita commented on COLLECTIONS-732:
------------------------------------------------

From your description it sounds like a good idea. Pull requests welcome :)

> Got an UnsupportedOperationException when using MultiValuedMap.MapIterator().setValue()
> ---------------------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-732
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-732
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Map
>            Reporter: Chen
>            Priority: Major
>
> copy from https://issues.apache.org/jira/browse/COLLECTIONS-663
> {code:java}
>     public void testSetValueMapIterator(){
>         final ListValuedMap<String, String> listMap = new ArrayListValuedHashMap<>();
>         List<String> listA = listMap.get("A");
>         listA.addAll(0, Arrays.asList("W", "X", "F"));
>         List<String> listB = listMap.get("B");
>         listB.addAll(0, Arrays.asList("Q", "Q", "L"));
>         assertEquals("{A=[W, X, F], B=[Q, Q, L]}", listMap.toString());
>         for(MapIterator<String, String> iterator = listMap.mapIterator(); iterator.hasNext(); ){
>             iterator.next();
>             String value = iterator.getValue();
>             if(value == "F"){
>                 iterator.setValue("B");
>             }
>         }
>         assertEquals("{A=[W, X, B], B=[Q, Q, L]}", listMap.toString());
>     }
> {code}
> It throws an UnsupportedOperationException when altering mapIterator().setValue()。
> I found UnsupportedOperationException is thrown in the code of setValue。So,if setValue method is not supported,the Javadoc should comment it。



--
This message was sent by Atlassian Jira
(v8.3.4#803005)