You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wink.apache.org by "Mike Rheinheimer (JIRA)" <ji...@apache.org> on 2010/07/23 16:02:06 UTC

[jira] Closed: (WINK-255) Iterator over map of SoftReferences susceptible to ConcurrentModificationException

     [ https://issues.apache.org/jira/browse/WINK-255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mike Rheinheimer closed WINK-255.
---------------------------------


> 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.