Bugs item #823649, was opened at 2003-10-14 12:30 Message generated for change (Comment added) made by starksm You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=376685&aid=823649&group_id=22866
Category: JBossMX Group: v3.2 >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Peter Stout (stottos) Assigned to: Scott M Stark (starksm) 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. ---------------------------------------------------------------------- >Comment By: Scott M Stark (starksm) Date: 2003-11-09 17:10 Message: Logged In: YES user_id=175228 I am just making a copy of the set which iteration is being done over to make sure the ConcurrentModificationException cannot happen. This is in for 3.2.3RC1 ---------------------------------------------------------------------- Comment By: Scott M Stark (starksm) Date: 2003-11-09 11:31 Message: Logged In: YES user_id=175228 Add a trace of the ConcurrentModificationException if you have it. The proposed synchronizations really should not have any effect because this does not prevent iteration over the pkg map from failing. I would think the real solution is another data structure like the EDU.oswego.cs.dl.util.concurrentConcurrentReaderHashMap ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=376685&aid=823649&group_id=22866 ------------------------------------------------------- This SF.Net email sponsored by: ApacheCon 2003, 16-19 November in Las Vegas. Learn firsthand the latest developments in Apache, PHP, Perl, XML, Java, MySQL, WebDAV, and more! http://www.apachecon.com/ _______________________________________________ JBoss-Development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development