Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Recoskie2011-05-02 17:37:56 +0000
committerChris Recoskie2011-05-02 17:37:56 +0000
commit8cd8d355be1f8291d94015a86a7294dd5fe10e73 (patch)
treef0c1c46e1a43ae98d60b3fea30ee96c9bb8d559f
parent7e74809492eb2d2bf058ce7e2c715eb44a30ca26 (diff)
downloadorg.eclipse.cdt-8cd8d355be1f8291d94015a86a7294dd5fe10e73.tar.gz
org.eclipse.cdt-8cd8d355be1f8291d94015a86a7294dd5fe10e73.tar.xz
org.eclipse.cdt-8cd8d355be1f8291d94015a86a7294dd5fe10e73.zip
Bug 133881 - Make refreshing after building optionalv201105021416
Fix ConcurrentModificationException by making RefreshScopeManager and friends threadsafe.
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ExclusionInstance.java24
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshExclusion.java38
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java42
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ResourceExclusion.java4
4 files changed, 54 insertions, 54 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ExclusionInstance.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ExclusionInstance.java
index 623dc61a7bb..7578eca707d 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ExclusionInstance.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ExclusionInstance.java
@@ -55,22 +55,22 @@ public class ExclusionInstance {
*
* @return RefreshExclusion
*/
- public RefreshExclusion getParentExclusion() {
+ public synchronized RefreshExclusion getParentExclusion() {
return fParent;
}
/**
* @param parent the RefreshExclusion to set as the parent.
*/
- public void setParentExclusion(RefreshExclusion parent) {
+ public synchronized void setParentExclusion(RefreshExclusion parent) {
fParent = parent;
}
- public ExclusionType getExclusionType() {
+ public synchronized ExclusionType getExclusionType() {
return fInstanceExclusionType;
}
- public void setExclusionType(ExclusionType type) {
+ public synchronized void setExclusionType(ExclusionType type) {
fInstanceExclusionType = type;
}
@@ -79,11 +79,11 @@ public class ExclusionInstance {
*
* @return IResource
*/
- public IResource getResource() {
+ public synchronized IResource getResource() {
return fResource;
}
- public void setResource(IResource resource) {
+ public synchronized void setResource(IResource resource) {
fResource = resource;
}
@@ -92,15 +92,15 @@ public class ExclusionInstance {
* Examples of this would be the resource name for a resource based exclusion, or the file extension
* excluded by a file extension exclusion.
*/
- public String getDisplayString() {
+ public synchronized String getDisplayString() {
return fDisplayString;
}
- public void setDisplayString(String displayString) {
+ public synchronized void setDisplayString(String displayString) {
fDisplayString = displayString;
}
- public void persistInstanceData(Document doc, Element exclusionElement) {
+ public synchronized void persistInstanceData(Document doc, Element exclusionElement) {
Element instanceElement = doc.createElement(INSTANCE_ELEMENT_NAME);
@@ -144,11 +144,11 @@ public class ExclusionInstance {
}
- protected void persistExtendedInstanceData(Document doc, Element instanceElement) {
+ protected synchronized void persistExtendedInstanceData(Document doc, Element instanceElement) {
// override to provide extension specific behaviour if desired
}
- public static ExclusionInstance loadInstanceData(Element instanceElement) {
+ public synchronized static ExclusionInstance loadInstanceData(Element instanceElement) {
String className = instanceElement.getAttribute(CLASS_ATTRIBUTE_NAME);
@@ -200,7 +200,7 @@ public class ExclusionInstance {
return newInstance;
}
- protected void loadExtendedInstanceData(Element instanceElement) {
+ protected synchronized void loadExtendedInstanceData(Element instanceElement) {
// override to provide extension specific behaviour if desired
}
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshExclusion.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshExclusion.java
index cb3aa9c6d0b..1e0a0550b51 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshExclusion.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshExclusion.java
@@ -67,7 +67,7 @@ public abstract class RefreshExclusion {
*
* @return IResource
*/
- public IResource getParentResource() {
+ public synchronized IResource getParentResource() {
return fParentResource;
}
@@ -76,7 +76,7 @@ public abstract class RefreshExclusion {
*
* @param parentResource the parent resource to set
*/
- public void setParentResource(IResource parentResource) {
+ public synchronized void setParentResource(IResource parentResource) {
this.fParentResource = parentResource;
}
@@ -84,11 +84,11 @@ public abstract class RefreshExclusion {
* @return a String corresponding to the ID of the RefreshExclusionContributor that was used to create
* this exclusion.
*/
- public String getContributorId() {
+ public synchronized String getContributorId() {
return fContributorId;
}
- public void setContributorId(String id) {
+ public synchronized void setContributorId(String id) {
fContributorId = id;
}
@@ -97,19 +97,19 @@ public abstract class RefreshExclusion {
*
* @return RefreshExclusion
*/
- public RefreshExclusion getParentExclusion() {
+ public synchronized RefreshExclusion getParentExclusion() {
return fParentExclusion;
}
- public void setParentExclusion(RefreshExclusion parent) {
+ public synchronized void setParentExclusion(RefreshExclusion parent) {
fParentExclusion = parent;
}
- public ExclusionType getExclusionType() {
+ public synchronized ExclusionType getExclusionType() {
return fExclusionType;
}
- public void setExclusionType(ExclusionType exclusionType) {
+ public synchronized void setExclusionType(ExclusionType exclusionType) {
fExclusionType = exclusionType;
}
@@ -134,7 +134,7 @@ public abstract class RefreshExclusion {
* @param resource the resource to be tested
* @return true if the exclusion is triggered, false otherwise (including if this exclusion does not apply)
*/
- public boolean testExclusionChain(IResource resource) {
+ public synchronized boolean testExclusionChain(IResource resource) {
// first check and see if this exclusion would be triggered in the first place
boolean currentValue = testExclusion(resource);
@@ -162,7 +162,7 @@ public abstract class RefreshExclusion {
/**
* @return an unmodifiable list of all the instance of this exclusion
*/
- public List<ExclusionInstance> getExclusionInstances() {
+ public synchronized List<ExclusionInstance> getExclusionInstances() {
return Collections.unmodifiableList(fExclusionInstanceList);
}
@@ -171,7 +171,7 @@ public abstract class RefreshExclusion {
*
* @param exclusionInstance
*/
- public void addExclusionInstance(ExclusionInstance exclusionInstance) {
+ public synchronized void addExclusionInstance(ExclusionInstance exclusionInstance) {
exclusionInstance.setParentExclusion(this);
fExclusionInstanceList.add(exclusionInstance);
}
@@ -181,7 +181,7 @@ public abstract class RefreshExclusion {
*
* @param exclusionInstance
*/
- public void removeExclusionInstance(ExclusionInstance exclusionInstance) {
+ public synchronized void removeExclusionInstance(ExclusionInstance exclusionInstance) {
fExclusionInstanceList.remove(exclusionInstance);
}
@@ -189,11 +189,11 @@ public abstract class RefreshExclusion {
*
* @return an unmodifiable list of exclusions to this exclusion.
*/
- public List<RefreshExclusion> getNestedExclusions() {
+ public synchronized List<RefreshExclusion> getNestedExclusions() {
return Collections.unmodifiableList(fNestedExclusions);
}
- public void addNestedExclusion(RefreshExclusion exclusion) {
+ public synchronized void addNestedExclusion(RefreshExclusion exclusion) {
fNestedExclusions.add(exclusion);
exclusion.setParentExclusion(this);
}
@@ -203,11 +203,11 @@ public abstract class RefreshExclusion {
*
* @param exclusion
*/
- public void removeNestedExclusion(RefreshExclusion exclusion) {
+ public synchronized void removeNestedExclusion(RefreshExclusion exclusion) {
fNestedExclusions.remove(exclusion);
}
- public void persistData(Document doc, Element parentElement) {
+ public synchronized void persistData(Document doc, Element parentElement) {
// persist the common data that all RefreshExclusions have
Element exclusionElement = doc.createElement(EXCLUSION_ELEMENT_NAME);
@@ -259,15 +259,15 @@ public abstract class RefreshExclusion {
}
}
- protected void persistExtendedData(Document doc, Element extensionElement) {
+ protected synchronized void persistExtendedData(Document doc, Element extensionElement) {
// override to provide extension specific behaviour if desired
}
- protected void loadExtendedData(Element parentElement) {
+ protected synchronized void loadExtendedData(Element parentElement) {
// override to provide extension specific behaviour if desired
}
- public static List<RefreshExclusion> loadData(Element parentElement, RefreshExclusion parentExclusion, IResource parentResource) throws CoreException {
+ public synchronized static List<RefreshExclusion> loadData(Element parentElement, RefreshExclusion parentExclusion, IResource parentResource) throws CoreException {
List<RefreshExclusion> exclusions = new LinkedList<RefreshExclusion>();
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java
index c839d926ffa..f5e603d1ed6 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java
@@ -203,13 +203,13 @@ public class RefreshScopeManager {
return fVersion;
}
- public RefreshExclusionFactory getFactoryForClassName(String className) {
+ public synchronized RefreshExclusionFactory getFactoryForClassName(String className) {
RefreshExclusionFactory factory = fClassnameToExclusionFactoryMap.get(className);
return factory;
}
- public RefreshExclusion getExclusionForClassName(String className) {
+ public synchronized RefreshExclusion getExclusionForClassName(String className) {
RefreshExclusionFactory factory = getFactoryForClassName(className);
if(factory == null) {
@@ -227,7 +227,7 @@ public class RefreshScopeManager {
* @param project
* @return List<IResource>
*/
- public List<IResource> getResourcesToRefresh(IProject project) {
+ public synchronized List<IResource> getResourcesToRefresh(IProject project) {
getProjectToResourcesMap();
LinkedHashSet<IResource> resources = fProjectToResourcesMap.get(project);
@@ -241,14 +241,14 @@ public class RefreshScopeManager {
return new LinkedList<IResource>(resources);
}
- public void setResourcesToRefresh(IProject project, List<IResource> resources) {
+ public synchronized void setResourcesToRefresh(IProject project, List<IResource> resources) {
getProjectToResourcesMap();
LinkedHashSet<IResource> resourceSet = new LinkedHashSet<IResource>(resources);
fProjectToResourcesMap.put(project, resourceSet);
}
- public void addResourceToRefresh(IProject project, IResource resource) {
+ public synchronized void addResourceToRefresh(IProject project, IResource resource) {
getProjectToResourcesMap();
LinkedHashSet<IResource> resourceSet = fProjectToResourcesMap.get(project);
@@ -261,7 +261,7 @@ public class RefreshScopeManager {
}
- public void deleteResourceToRefresh(IProject project, IResource resource) {
+ public synchronized void deleteResourceToRefresh(IProject project, IResource resource) {
getProjectToResourcesMap();
LinkedHashSet<IResource> resourceSet = fProjectToResourcesMap.get(project);
@@ -273,7 +273,7 @@ public class RefreshScopeManager {
resourceSet.remove(resource);
}
- public void clearResourcesToRefresh(IProject project) {
+ public synchronized void clearResourcesToRefresh(IProject project) {
getProjectToResourcesMap();
LinkedHashSet<IResource> resourceSet = fProjectToResourcesMap.get(project);
@@ -287,11 +287,11 @@ public class RefreshScopeManager {
}
- public void clearAllResourcesToRefresh() {
+ public synchronized void clearAllResourcesToRefresh() {
fProjectToResourcesMap.clear();
}
- public void clearAllData() {
+ public synchronized void clearAllData() {
clearAllResourcesToRefresh();
clearAllExclusions();
}
@@ -304,7 +304,7 @@ public class RefreshScopeManager {
return fProjectToResourcesMap;
}
- public List<RefreshExclusion> getExclusions(IResource resource) {
+ public synchronized List<RefreshExclusion> getExclusions(IResource resource) {
getResourcesToExclusionsMap();
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
if(exclusions == null) {
@@ -315,7 +315,7 @@ public class RefreshScopeManager {
return exclusions;
}
- public void addExclusion(IResource resource, RefreshExclusion exclusion) {
+ public synchronized void addExclusion(IResource resource, RefreshExclusion exclusion) {
getResourcesToExclusionsMap();
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
@@ -335,7 +335,7 @@ public class RefreshScopeManager {
return fResourceToExclusionsMap;
}
- public void removeExclusion(IResource resource, RefreshExclusion exclusion) {
+ public synchronized void removeExclusion(IResource resource, RefreshExclusion exclusion) {
getResourcesToExclusionsMap();
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
if(exclusions == null) {
@@ -346,7 +346,7 @@ public class RefreshScopeManager {
exclusions.remove(exclusion);
}
- public void persistSettings() throws CoreException {
+ public synchronized void persistSettings() throws CoreException {
getProjectToResourcesMap();
getResourcesToExclusionsMap();
for(IProject project : fProjectToResourcesMap.keySet()) {
@@ -415,7 +415,7 @@ public class RefreshScopeManager {
}
}
- public void loadSettings() throws CoreException {
+ public synchronized void loadSettings() throws CoreException {
// iterate through all projects in the workspace. If they are C projects, attempt to load settings
// from them.
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
@@ -430,7 +430,7 @@ public class RefreshScopeManager {
* @param project
* @throws CoreException
*/
- private void loadSettings(IWorkspaceRoot workspaceRoot, IProject project) throws CoreException {
+ private synchronized void loadSettings(IWorkspaceRoot workspaceRoot, IProject project) throws CoreException {
if (project.isOpen()) {
if (project.hasNature(CProjectNature.C_NATURE_ID)) {
String xmlString = project.getPersistentProperty(REFRESH_SCOPE_PROPERTY_NAME);
@@ -523,7 +523,7 @@ public class RefreshScopeManager {
}
}
- public void clearExclusions(IResource resource) {
+ public synchronized void clearExclusions(IResource resource) {
getResourcesToExclusionsMap();
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
if(exclusions != null) {
@@ -531,7 +531,7 @@ public class RefreshScopeManager {
}
}
- public void setExclusions(IResource resource, List<RefreshExclusion> newExclusions) {
+ public synchronized void setExclusions(IResource resource, List<RefreshExclusion> newExclusions) {
getResourcesToExclusionsMap();
List<RefreshExclusion> exclusions = new LinkedList<RefreshExclusion>(newExclusions);
@@ -543,7 +543,7 @@ public class RefreshScopeManager {
fResourceToExclusionsMap.clear();
}
- public void clearExclusionsForProject(IProject project) {
+ public synchronized void clearExclusionsForProject(IProject project) {
getResourcesToExclusionsMap();
for(IResource resource : fResourceToExclusionsMap.keySet()) {
IProject project2 = resource.getProject();
@@ -553,12 +553,12 @@ public class RefreshScopeManager {
}
}
- private void clearDataForProject(IProject project) {
+ private synchronized void clearDataForProject(IProject project) {
clearResourcesToRefresh(project);
clearExclusionsForProject(project);
}
- public ExclusionInstance getInstanceForClassName(String className) {
+ public synchronized ExclusionInstance getInstanceForClassName(String className) {
RefreshExclusionFactory factory = getFactoryForClassName(className);
if(factory == null) {
@@ -607,7 +607,7 @@ public class RefreshScopeManager {
return runnable;
}
- public boolean shouldResourceBeRefreshed(IResource resource) {
+ public synchronized boolean shouldResourceBeRefreshed(IResource resource) {
IProject project = resource.getProject();
List<IResource> resourcesToRefresh = getResourcesToRefresh(project);
boolean isInSomeTree = false;
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ResourceExclusion.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ResourceExclusion.java
index 08d6c5d5cee..13238c876a1 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ResourceExclusion.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ResourceExclusion.java
@@ -34,7 +34,7 @@ public class ResourceExclusion extends RefreshExclusion {
* @see org.eclipse.cdt.core.resources.RefreshExclusion#getName()
*/
@Override
- public String getName() {
+ public synchronized String getName() {
return Messages.ResourceExclusion_name;
}
@@ -42,7 +42,7 @@ public class ResourceExclusion extends RefreshExclusion {
* @see org.eclipse.cdt.core.resources.RefreshExclusion#testExclusion(org.eclipse.core.resources.IResource)
*/
@Override
- public boolean testExclusion(IResource resource) {
+ public synchronized boolean testExclusion(IResource resource) {
//Populate the resources to be excluded by this exclusion
List<IResource> excludedResources = new LinkedList<IResource>();

Back to the top