[jboss-jira] [JBoss JIRA] Created: (JBAS-6381) ConcurrentModification in UnifiedLoaderRepository3 packagesMap

Adrian Brock (JIRA) jira-events at lists.jboss.org
Wed Jan 14 05:27:04 EST 2009


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