Community
Participate
Working Groups
The method ModelDescriptorRegistry#internalGetModel(IFile) creates a copy of a Set which was created by Collections#synchronizedSet(Set) as follows: Set<IModelDescriptor> unsynchronizedModelDescriptorsForMMDescriptor = new HashSet<IModelDescriptor>(modelDescriptorsForMMDescriptor); The problem is, that the constructor of the HashSet iterates over the set to copy without protecting it against concurrent access which must be done manually with a synchronized statement as documented in Collections#synchronizedSet(Set). Consequently, a ConcurrentModificationException is thrown by the constructor of the HashSet in case of concurrent access. The obvious solution is: synchronized (modelDescriptorsForMMDescriptor) { Set<IModelDescriptor> unsynchronizedModelDescriptorsForMMDescriptor = new HashSet<IModelDescriptor>(modelDescriptorsForMMDescriptor); } Please test carefully, that no deadlocks are introduced related to comment with the "Important Note".
The following methods should be adjusted as well: - ModelDescriptorRegistry#internalGetModel(Resource) - ModelDescriptorRegistry#getOldModel(IFile) - ModelDescriptorRegistry#getOldModel(Resource) - ModelDescriptorRegistry#internalGetModel(IResource, IMetaModelDescriptor) - ModelDescriptorRegistry#getModels(IProject) - ModelDescriptorRegistry#getModels(IWorkspaceRoot) - ModelDescriptorRegistry#getAllModels(IMetaModelDescriptor) => Return unmodifiable copy so that concurrent access is possible
Change the visibility from ModelDescriptorRegistry#modelDescriptors from protected to private to ensure that nobody else iterates over the sets, thus deadlocks can hopefully be excluded.
Closed stale issue before migration