commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chen (Jira)" <j...@apache.org>
Subject [jira] [Created] (COLLECTIONS-732) Appeared UnsupportedOperationException when altering MultiValuedMap MapIterator setValue
Date Tue, 05 Nov 2019 12:37:00 GMT
Chen created COLLECTIONS-732:
--------------------------------

             Summary: Appeared UnsupportedOperationException when altering 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


copy from https://issues.apache.org/jira/browse/COLLECTIONS-663
{code:java}

    public void testSetValueMapIterator(){
        final ListValuedMap<K, V> listMap = makeObject();
        List<V> listA = listMap.get((K) "A");
        listA.addAll(0, Arrays.asList((V) "W", (V) "X", (V) "F"));
        List<V> listB = listMap.get((K) "B");
        listB.addAll(0, Arrays.asList((V) "Q", (V) "Q", (V) "L"));
        assertEquals("{A=[W, X, F], B=[Q, Q, L]}", listMap.toString());        for(MapIterator<K,
V> iterator = listMap.mapIterator(); iterator.hasNext(); ){
            iterator.next();
            V value = iterator.getValue();
            if(value == "F"){
                iterator.setValue((V) "B");
            }
        }
        assertEquals("{A=[W, X, B], B=[Q, Q, L]}", listMap.toString());
    }
{code}
The test throws a UnsupportedOperationException when altering mapIterato setValue。

The issue is that the code throws UnsupportedOperationException  in setValue。So,if setValue
method is not supported,the Javadoc should comment。



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

Mime
View raw message