[
https://issues.apache.org/jira/browse/SLING-4903?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14640388#comment-14640388
]
Chetan Mehrotra commented on SLING-4903:
----------------------------------------
If the write is not concurrent i.e. 2 thread writing to the list at same time
then instead of using CopyOnWriteArrayList you can just clone existing list
(copy content to new) and then replace the entry in the map with new sorted
list. This would ensure list is not modified while an iterator is opened
> ConcurrentModificationException in MapEntries
> ---------------------------------------------
>
> Key: SLING-4903
> URL: https://issues.apache.org/jira/browse/SLING-4903
> Project: Sling
> Issue Type: Bug
> Components: ResourceResolver
> Reporter: Antonio Sanso
> Assignee: Antonio Sanso
> Attachments: SLING-4883-patch.txt, SLING-4883-test-patch.txt
>
>
> {code}
> org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught
> Throwable java.util.ConcurrentModificationException: null
> at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:859)
> at java.util.ArrayList$Itr.next(ArrayList.java:831)
> at
> org.apache.sling.resourceresolver.impl.mapping.MapEntries$MapEntryIterator.seek(MapEntries.jav
> a:1499)
> at
> org.apache.sling.resourceresolver.impl.mapping.MapEntries$MapEntryIterator.next(MapEntries.jav
> a:1450)
> at
> org.apache.sling.resourceresolver.impl.mapping.MapEntries$MapEntryIterator.next(MapEntries.jav
> a:1411)
> at
> org.apache.sling.resourceresolver.impl.ResourceResolverImpl.resolveInternal(ResourceResolverIm
> pl.java:251)
> at
> org.apache.sling.resourceresolver.impl.ResourceResolverImpl.resolve(ResourceResolverImpl.java:
> 192)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)