Skip to content

Commit

Permalink
Fix potential ConcurrentModificationException during parallel load.
Browse files Browse the repository at this point in the history
Access the SourceLevelURIsAdapter before the ParallelResourceLoader
starts as there can be ConcurrentModificationExceptions if one thread
modifies the adapters list while another constructs its thread local
resource set.
  • Loading branch information
andrewL-avlq committed Apr 26, 2024
1 parent 2ac820e commit 5df0222
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,14 @@ public ParallelLoadOperation(final ResourceSet parent, final IProject project) {
} else {
this.resourceQueue = new ArrayBlockingQueue<Triple<URI, Resource, Throwable>>(queueSize);
}
final boolean parentIsIndexing = BuildPhases.isIndexing(parent);
final Set<URI> parentSourceLevelUris = SourceLevelURIsAdapter.findInstalledAdapter(parent).getSourceLevelURIs();
this.resourceSetProvider = new ThreadLocal<ResourceSet>() {
@Override
protected ResourceSet initialValue() {
ResourceSet resourceSet = getResourceSetProvider().get(project);
BuildPhases.setIndexing(resourceSet, BuildPhases.isIndexing(parent));
SourceLevelURIsAdapter.setSourceLevelUrisWithoutCopy(resourceSet, SourceLevelURIsAdapter.findInstalledAdapter(parent).getSourceLevelURIs());
BuildPhases.setIndexing(resourceSet, parentIsIndexing);
SourceLevelURIsAdapter.setSourceLevelUrisWithoutCopy(resourceSet, parentSourceLevelUris);
resourceSet.getLoadOptions().putAll(parent.getLoadOptions());
// we are not loading as part of a build
resourceSet.getLoadOptions().remove(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE);
Expand Down

0 comments on commit 5df0222

Please sign in to comment.