[jboss-jira] [JBoss JIRA] Commented: (JBAS-6381) ConcurrentModification in UnifiedLoaderRepository3 packagesMap
Adrian Brock (JIRA)
jira-events at lists.jboss.org
Wed Jan 14 10:29:14 EST 2009
[ https://jira.jboss.org/jira/browse/JBAS-6381?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12447782#action_12447782 ]
Adrian Brock commented on JBAS-6381:
------------------------------------
For now I've just synchronized the TreeSets but this could obviously be done more efficiently
(if the code wasn't so complicated to change. :-)
[ejort at warjort jboss-4.2]$ svn diff
Index: jmx/src/main/org/jboss/mx/loading/ClassLoaderUtils.java
===================================================================
--- jmx/src/main/org/jboss/mx/loading/ClassLoaderUtils.java (revision 82864)
+++ jmx/src/main/org/jboss/mx/loading/ClassLoaderUtils.java (working copy)
@@ -35,6 +35,7 @@
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
@@ -222,7 +223,7 @@
*/
public static Set newPackageSet()
{
- return new TreeSet(repostiroyClassLoaderComparator);
+ return Collections.synchronizedSet(new TreeSet(repostiroyClassLoaderComparator));
}
/**
> ConcurrentModification in UnifiedLoaderRepository3 packagesMap
> --------------------------------------------------------------
>
> Key: JBAS-6381
> URL: https://jira.jboss.org/jira/browse/JBAS-6381
> Project: JBoss Application Server
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: ClassLoading
> Affects Versions: JBossAS-4.2.3.GA
> Reporter: Adrian Brock
> Assignee: Scott M Stark
>
> The UnifiedLoaderRepository3 has an internal packagesMap
> which is currently a
> ConcurrentHashMap<String, TreeSet<UnfiedClassLoader>>
> where the TreeSet uses a comparator based on the PkgClassLoader/UnifiedClassLoader order.
> This TreeSet is not properly synchronized against changes, e.g. (un)deployment of a classloader that
> has a certain package while somebody is trying to load a class from that package.
> This can lead to a
> java.util.ConcurrentModificationException
> at java.util.HashMap$HashIterator.nextEntry(HashMap.java:841)
> at java.util.HashMap$KeyIterator.next(HashMap.java:877)
> at java.util.AbstractCollection.addAll(AbstractCollection.java:318)
> at java.util.TreeSet.addAll(TreeSet.java:258)
> at org.jboss.mx.loading.UnifiedLoaderRepository3.getPackageClassLoaders(UnifiedLoaderRepository3.java:246)
> at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:178)
> at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:514)
> at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:408)
> Rather than synchronizing the TreeSet, I'd suggest using a CopyOnWriteList whose
> contents are presorted like the TreeSet.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list