| Summary: | ConcurrentModificationException on faceted project creation | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [WebTools] WTP Common Tools | Reporter: | Kevin Tapperson <kevintap> | ||||||
| Component: | wst.common | Assignee: | Chuck Bridgham <cbridgha> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | Carl Anderson <ccc> | ||||||
| Severity: | normal | ||||||||
| Priority: | P3 | Flags: | ccc:
review+
|
||||||
| Version: | 3.1 | ||||||||
| Target Milestone: | 3.2.3 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Linux | ||||||||
| Whiteboard: | |||||||||
| Bug Depends on: | |||||||||
| Bug Blocks: | 351599 | ||||||||
| Attachments: |
|
||||||||
|
Description
Kevin Tapperson
Created attachment 183627 [details]
stack traces of the offending threads as caught in the debugger
This attachment contains 2 stack traces from the offending threads involved in the ConcurrentModificationException.
The ModalContext thread is the thread where our new project wizard is running. It has created a new project, added the wst web facet and our custom facet to the project. The facet framework is currently in the process of performing the completion steps of adding the new facets to the project and is broadcasting the post change event. The thread appears to be examining all of the new resources added to the project to see if they should be added to a ProjectResourceSetImpl$SynchronizedResourcesEList collection. The thread appears to obtain this collection for each new resource then iterate through the collection. This process can take a bit of time as the number of new files in the project is large (approx 500-600 files).
The Worker-1 thread appears to be running a job called LoadingDDJob and is also working with the same ProjectResourceSetImpl$SynchronizedResourcesEList collection. If this thread makes a call to add an item to the collection while the first thread (ModalContext) is iterating over the collection, the ConcurrentModificationException is thrown.
Assigning to Chuck for initial investigation. Also, the facet in question must be jst.web, not wst.web - it is loading the JavaArtifactEditModel in Worker-1 (and would not attempt the loadingDD job for wst.web, since Static Web projects do not have a Deployment Descriptor.) looking to re-implement getResources() to always return a copy and would delegate any modifications to the internal List for notifications etc... Created attachment 184191 [details]
possible patch
I made the method for getting a seperate copy of the resources public, so the synchronizer could use that. For safety reasons - I also delegated any "write" operation back to the original collection - but in these cases - only read scenarios are using the call. I made a tweak to the patch to do the following in the synchronizer for safety if the resourceSet is not the type I'm expecting...
if (resourceSet instanceof ProjectResourceSetImpl) {
ProjectResourceSetImpl projResSet = (ProjectResourceSetImpl)resourceSet;
allResources = projResSet.getImmutableResources();
} else {
allResources = resourceSet.getResources();
}
Chuck, did you mean to attach an additional patch with the updated check? Yes - thanks... this is checked in... |