Thanks for so detailed explanation. So, we have two maps, one is fileCache,
its key type is unknown (might be string/uri/url etc), and the value type is
JarFile. Also. another map is ucf, its key type is JarFile, and its value
type is URL.
I am not sure why the line JarFile jarFile = fileCache.remove(key) is not
safe, as all those keys are got from the same map fileCache from the codes :
--->
for (Map.Entry<Object, JarFile> entry : fileCache.entrySet()) {
    if (isParent(jarLocation, new File(entry.getValue().getName()))) {
        removedKeys.add(entry.getKey());
    }
}
<---
For the ConcurrentModifiedException , I think that there is no way to avoid
totally, as it looks that no way to lock the two maps. One possible way is
to create a snapshot in the first loop, which I saw you did the similar
thing in one of your comments, while we might still get exception in the
process of creating the snapshot. Thoughts ?
Thanks.


2011/7/19 AndyG <[email protected]>

> So basically what I am saying is:
>
> for(Object key : removedKeys) {
>    JarFile jarFile = fileCache.remove(key);
>
> ... Is not safe, as Object key may not be the actual key in the other map
> (even though it was intended to be so)
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Re-svn-commit-r1146747-openejb-trunk-openejb3-container-openejb-core-src-main-java-org-apache-openeja-tp3674308p3677845.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>



-- 
Ivan

Reply via email to