Bugs item #823649, was opened at 2003-10-14 12:30
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=823649&group_id=22866

Category: JBossMX
Group: v3.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Peter Stout (stottos)
Assigned to: Nobody/Anonymous (nobody)
Summary: ConcurrentModificationException in UnifiedLoaderRepository3

Initial Comment:
The getResourceFromRepository method in
UnifiedLoaderRepository3 does not synchronize access to
the packagesMap and classLoaders fields, unlike all
other accesses to those fields.  As a result, if
classes are being loaded at the same time as a resource
is being looked up, a ConcurrentModificationException
can be triggered.

I have attached a proposed patch for this bug.  The fix
wraps the uses of packagesMap and classLoaders fields
in the appropriate synchronized blocks.  If the all of
the class loaders need to be searched, a copy of the
classLoaders field is made to avoid having to
synchronize while performing the search.  The existing
code is inconsistent in the way it makes a copy of the
classLoaders field: new HashSet(classLoaders) versus
classLoaders.clone().  I arbitrarily chose the former,
but whoever fixes the bug might consider making the
code consistent one way or the other.

I suspect that there is a second order synchronization
problem in the processing of any HashSet retrieved from
the packagesMap.  The retrieved HashSet may be
concurrently modified if a class loader is added or
removed while the set is being processed.  The
modifications to the HashSet's in the packagesMap
performed in the add/remove class loader code path are
performed while holding the packagesMap lock, but the
code in getResourceFromRepository and
LoadMgr3.beginLoadTask, which retrieves a package set
using the getPackageClassLoaders method, is
unsynchronized.  Unless there is some other lock that
makes this a non-issue, I suspect that fixing the
problem will require either making a copy of the
HashSet or a moderate amount of code restructuring.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=823649&group_id=22866


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to