Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323585

Summary: ConcurrentModificationException during "Loading referenced grammars"
Product: [WebTools] WTP Source Editing Reporter: Jesper Moller <jesper>
Component: wst.xmlAssignee: Rakesh <rakes123>
Status: RESOLVED FIXED QA Contact: Nitin Dahyabhai <thatnitind>
Severity: normal    
Priority: P3 CC: mauromol, nsand.dev, rakes123
Version: 3.2.1Flags: nsand.dev: review+
Target Milestone: 3.3.1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
patch nsand.dev: iplog+

Description Jesper Moller CLA 2010-08-25 06:02:00 EDT
I got an error during startup, where my workspace had a schema file loaded which relied on catalog entries.
This must have crossed with schema contributions from one of the many plugins present (full WTP + OEPE + Spring STS)

The Catalog needs to protect itself from concurrent access.

java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(Unknown Source)
at java.util.AbstractList$Itr.next(Unknown Source)
at org.eclipse.wst.xml.core.internal.catalog.Catalog$InternalResolver.<init>(Catalog.java:142)
at org.eclipse.wst.xml.core.internal.catalog.Catalog.getOrCreateInternalResolver(Catalog.java:636)
at org.eclipse.wst.xml.core.internal.catalog.Catalog.resolveSystem(Catalog.java:745)
at org.eclipse.wst.xml.core.internal.catalog.Catalog.resolveSubordinateCatalogs(Catalog.java:725)
at org.eclipse.wst.xml.core.internal.catalog.Catalog$InternalResolver.resolveSystem(Catalog.java:293)
at org.eclipse.wst.xml.core.internal.catalog.Catalog.resolveSystem(Catalog.java:745)
at org.eclipse.wst.xml.core.internal.catalog.XMLCatalogURIResolverExtension.resolve(XMLCatalogURIResolverExtension.java:46)
at org.eclipse.wst.common.uriresolver.internal.ExtensibleURIResolver.resolve(ExtensibleURIResolver.java:85)
at org.eclipse.wst.xml.core.internal.modelquery.XMLCatalogIdResolver.resolve(XMLCatalogIdResolver.java:92)
at org.eclipse.wst.xml.core.internal.modelquery.XMLModelQueryAssociationProvider.resolveGrammarURI(XMLModelQueryAssociationProvider.java:58)
at org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.XMLAssociationProvider.resolveGrammarURI(XMLAssociationProvider.java:160)
at org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentManagerImpl.lookupOrCreateResolvedURI(CMDocumentManagerImpl.java:122)
at org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentManagerImpl.addCMDocumentReference(CMDocumentManagerImpl.java:204)
at org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentLoader.handleGrammar(CMDocumentLoader.java:105)
at org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentLoader$CMDocumentLoadingNamespaceTable.addElement(CMDocumentLoader.java:180)
at org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentLoader.loadCMDocuments(CMDocumentLoader.java:74)
at org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.InferredGrammarBuildingCMDocumentLoader.loadCMDocuments(InferredGrammarBuildingCMDocumentLoader.java:56)
at org.eclipse.wst.xml.ui.internal.DOMObserver.invokeCMDocumentLoad(DOMObserver.java:203)
at org.eclipse.wst.xml.ui.internal.DOMObserver$TimerJob.run(DOMObserver.java:142)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


eclipse.buildId=I20100608-0911
java.version=1.6.0_20
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=da_DK
Command-line arguments:  -os win32 -ws win32 -arch x86
Comment 1 Rakesh CLA 2010-08-26 05:18:18 EDT
Created attachment 177508 [details]
patch

I synchronized on whole constructor and not just Iterator to avoid creation of more than one InternalResolvers.Constructor is taking negligible time(tested).Other lists seem to be safe , as they are modified only in constructor.listenerList is also not thread safe.
Comment 2 Nick Sandonato CLA 2010-10-04 17:11:22 EDT
Passing to Gabriel for review since this pertains to Catalog.
Comment 3 Mauro Molinari CLA 2011-04-05 00:58:15 EDT
I encountered this problem too, with the same stack trace.
Comment 4 Nick Sandonato CLA 2011-06-15 17:26:12 EDT
Patch looks OK. Modified it a bit to account for the clearing of the list and also what the lock is.