[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jakarta-commons-dev
Subject:    [jira] [Work logged] (COLLECTIONS-663) Unexpected ConcurrentModificationException when altering Coll
From:       "ASF GitHub Bot (Jira)" <jira () apache ! org>
Date:       2020-04-30 1:18:00
Message-ID: JIRA.13116181.1509817109000.68848.1588209480169 () Atlassian ! JIRA
[Download RAW message or body]


     [ https://issues.apache.org/jira/browse/COLLECTIONS-663?focusedWorklogId=428825&p \
age=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-428825 ]

ASF GitHub Bot logged work on COLLECTIONS-663:
----------------------------------------------

                Author: ASF GitHub Bot
            Created on: 30/Apr/20 01:17
            Start Date: 30/Apr/20 01:17
    Worklog Time Spent: 10m 
      Work Description: coveralls commented on pull request #110:
URL: https://github.com/apache/commons-collections/pull/110#issuecomment-621555280


   
   [![Coverage Status](https://coveralls.io/builds/30449475/badge)](https://coveralls.io/builds/30449475)
  
   Coverage decreased (-0.09%) to 90.034% when pulling \
**58ec415bf585b5bf7c6c4ce4fa8e406b529eaf89 on dota17:AbstractMultiValuedMap** into \
**a3eb3be4b0063351115a02f56c884b31a6cc8bff on apache:master**.  


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 428825)
    Time Spent: 0.5h  (was: 20m)

> Unexpected ConcurrentModificationException when altering Collection of a \
>                 MultiValuedMap
> ---------------------------------------------------------------------------------------
>  
> Key: COLLECTIONS-663
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-663
> Project: Commons Collections
> Issue Type: Bug
> Reporter: Christophe Schmaltz
> Assignee: Bruno P. Kinoshita
> Priority: Trivial
> Time Spent: 0.5h
> Remaining Estimate: 0h
> 
> Testcase:
> {code}	@Test
> 	public void test() {
> 		MultiValuedMap<Integer, Integer> multiMap = new HashSetValuedHashMap<>();
> 		multiMap.put(1, 10);
> 		multiMap.put(2, 20);
> 		for (Collection<Integer> innerCollection : multiMap.asMap().values()) {
> 			for (Iterator<Integer> iterator = innerCollection.iterator(); \
> iterator.hasNext();) {  Integer i = iterator.next();
> 				iterator.remove(); // only the innerCollection is altered
> 			}
> 			// innerCollection.add(6); // adding stuff back should also work...
> 		}
> 	}{code}
> This test unexpectedly throws a ConcurrentModificationException.
> The issue is that when calling {{iterator.remove()}} the \
> {{AbstractMultiValuedMap.ValuesIterator}} detects that the Collection is empty and \
> calls {{AbstractMultiValuedMap.this.remove(key);}}. It may be better if the \
> iterator of the inner collection had a reference on the iterator if the outer map \
>                 and called {{containerIterator.remove()}} instead.
> *Note:* this solution would again present issues if the user tries to add new \
> elements in this now empty collection (which was removed from the parent). In the \
> current state, it is quite unclear why an exception is thrown, without debugging \
> the code. 



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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic