[
https://issues.apache.org/jira/browse/WINK-255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mike Rheinheimer resolved WINK-255.
-----------------------------------
Resolution: Fixed
Committed in SVN 912204.
> Iterator over map of SoftReferences susceptible to
> ConcurrentModificationException
> ----------------------------------------------------------------------------------
>
> Key: WINK-255
> URL: https://issues.apache.org/jira/browse/WINK-255
> Project: Wink
> Issue Type: Bug
> Components: Common
> Affects Versions: 1.1
> Reporter: Mike Rheinheimer
> Fix For: 1.1
>
> Attachments: WINK-255.patch
>
>
> In org/apache/wink/common/internal/utils/SoftConcurrentMap.put, a copy of the
> map is made by calling the WeakHashMap(Map) copy constructor.
> Under the WeakHashMap(Map) constructor, java.util.AbstractMap.putAll is
> called, which uses an iterator. Iterators, as we all know, are not
> thread-safe; they are susceptible to ConcurrentModificationExceptions. Note
> that this method is already 'synchronized'. However, that does not protect
> this.map from the silent garbage collector thread, which may remove something
> at any time due to the internal values being "SoftReferences". Instead of
> synchronizing on this.map, let's just catch ConcurrentModificationException
> ignore it, and retry in the while loop.
> Please see the patch. I have tested this many times in a multi-threaded
> environment, and even done performance testing on it. The fix looks good.
> However, I'll leave it up for a few days in case anyone has a better idea
> before I commit it.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.