Patch for Briany (43833,180,000)
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/PropertyManager.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/PropertyManager.java
index e456c34..24d859f 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/PropertyManager.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/PropertyManager.java
@@ -22,7 +22,7 @@
import org.eclipse.core.runtime.*;
/**
- *
+ *
*/
public class PropertyManager implements IManager, ILifecycleListener {
protected Workspace workspace;
@@ -31,33 +31,27 @@
this.workspace = workspace;
}
- public void closePropertyStore(IResource target) throws CoreException {
+ public synchronized void closePropertyStore(IResource target) throws CoreException {
PropertyStore store = getPropertyStoreOrNull(target);
if (store == null)
return;
- synchronized (store) {
- store.shutdown(null);
- setPropertyStore(target, null);
- }
+ store.shutdown(null);
+ setPropertyStore(target, null);
}
/**
- * Copy all the properties of one resource to another. Both resources
- * must have a property store available.
+ * Copy all the properties of one resource to another. Both resources must
+ * have a property store available.
*/
- public void copy(IResource source, IResource destination, int depth) throws CoreException {
+ public synchronized void copy(IResource source, IResource destination, int depth) throws CoreException {
// cache stores to avoid problems in concurrency
PropertyStore sourceStore = getPropertyStore(source);
PropertyStore destinationStore = getPropertyStore(destination);
- synchronized (sourceStore) {
- assertRunning(source, sourceStore);
- synchronized (destinationStore) {
- assertRunning(destination, destinationStore);
- copyProperties(source, destination, depth);
- sourceStore.commit();
- destinationStore.commit();
- }
- }
+ assertRunning(source, sourceStore);
+ assertRunning(destination, destinationStore);
+ copyProperties(source, destination, depth);
+ sourceStore.commit();
+ destinationStore.commit();
}
/**
@@ -65,14 +59,15 @@
*/
private void assertRunning(IResource target, PropertyStore store) throws CoreException {
if (!store.isRunning()) {
- //if the store is not running then the resource is in the process of being deleted,
- //so report the error as if the resource was not found
+ // if the store is not running then the resource is in the process
+ // of being deleted,
+ // so report the error as if the resource was not found
String message = Policy.bind("resources.mustExist", target.getFullPath().toString()); //$NON-NLS-1$
throw new ResourceException(IResourceStatus.RESOURCE_NOT_FOUND, target.getFullPath(), message, null);
}
}
- protected void copyProperties(IResource source, IResource destination, int depth) throws CoreException {
+ private void copyProperties(IResource source, IResource destination, int depth) throws CoreException {
PropertyStore sourceStore = getPropertyStore(source);
PropertyStore destStore = getPropertyStore(destination);
ResourceName sourceName = getPropertyKey(source);
@@ -92,54 +87,51 @@
}
}
- public void deleteProperties(IResource target, int depth) throws CoreException {
+ public synchronized void deleteProperties(IResource target, int depth) throws CoreException {
switch (target.getType()) {
- case IResource.FILE :
- case IResource.FOLDER :
- PropertyStore store = getPropertyStore(target);
- synchronized (store) {
- assertRunning(target, store);
- store.removeAll(getPropertyKey(target), depth);
- store.commit();
- }
- break;
- case IResource.PROJECT :
- case IResource.ROOT :
- deletePropertyStore(target, true);
+ case IResource.FILE:
+ case IResource.FOLDER:
+ PropertyStore store = getPropertyStore(target);
+ assertRunning(target, store);
+ store.removeAll(getPropertyKey(target), depth);
+ store.commit();
+ break;
+ case IResource.PROJECT:
+ case IResource.ROOT:
+ deletePropertyStore(target, true);
}
}
/**
- * The resource is being deleted so permanently erase its properties.
- * In the case of projects, this means the property store will not be
- * accessible again.
+ * The resource is being deleted so permanently erase its properties. In the
+ * case of projects, this means the property store will not be accessible
+ * again.
*/
- public void deleteResource(IResource target) throws CoreException {
+ public synchronized void deleteResource(IResource target) throws CoreException {
switch (target.getType()) {
- case IResource.FILE :
- case IResource.FOLDER :
- case IResource.ROOT :
- deleteProperties(target, IResource.DEPTH_INFINITE);
- break;
- case IResource.PROJECT :
- //permanently delete the store
- deletePropertyStore(target, false);
+ case IResource.FILE:
+ case IResource.FOLDER:
+ case IResource.ROOT:
+ deleteProperties(target, IResource.DEPTH_INFINITE);
+ break;
+ case IResource.PROJECT:
+ // permanently delete the store
+ deletePropertyStore(target, false);
}
}
- protected void deletePropertyStore(IResource target, boolean restart) throws CoreException {
+ private void deletePropertyStore(IResource target, boolean restart) throws CoreException {
PropertyStore store = getPropertyStoreOrNull(target);
if (store == null)
return;
- synchronized (store) {
- store.shutdown(null);
- workspace.getMetaArea().getPropertyStoreLocation(target).toFile().delete();
- //if we want to allow restart, null the store and it will be recreated lazily
- if (restart) {
- ResourceInfo info = getPropertyHost(target).getResourceInfo(false, false);
- if (info != null)
- info.setPropertyStore(null);
- }
+ store.shutdown(null);
+ workspace.getMetaArea().getPropertyStoreLocation(target).toFile().delete();
+ // if we want to allow restart, null the store and it will be recreated
+ // lazily
+ if (restart) {
+ ResourceInfo info = getPropertyHost(target).getResourceInfo(false, false);
+ if (info != null)
+ info.setPropertyStore(null);
}
}
@@ -147,37 +139,37 @@
* Returns the value of the identified property on the given resource as
* maintained by this store.
*/
- public String getProperty(IResource target, QualifiedName name) throws CoreException {
+ public synchronized String getProperty(IResource target, QualifiedName name) throws CoreException {
PropertyStore store = getPropertyStore(target);
- synchronized (store) {
- assertRunning(target, store);
- StoredProperty result = store.get(getPropertyKey(target), name);
- return result == null ? null : result.getStringValue();
- }
+ assertRunning(target, store);
+ StoredProperty result = store.get(getPropertyKey(target), name);
+ return result == null ? null : result.getStringValue();
}
/**
- * Returns the resource which hosts the property store
- * for the given resource.
+ * Returns the resource which hosts the property store for the given
+ * resource.
*/
- protected Resource getPropertyHost(IResource target) {
+ private Resource getPropertyHost(IResource target) {
return (Resource) (target.getType() == IResource.ROOT ? target : target.getProject());
}
/**
- * Returns the key to use in the property store when accessing
- * the properties of the given resource.
+ * Returns the key to use in the property store when accessing the
+ * properties of the given resource.
*/
- protected ResourceName getPropertyKey(IResource target) {
+ private ResourceName getPropertyKey(IResource target) {
return new ResourceName("", target.getProjectRelativePath()); //$NON-NLS-1$
}
/**
- * Returns the property store to use when storing a property for the
- * given resource.
- * @throws CoreException if the store could not be obtained for any reason.
+ * Returns the property store to use when storing a property for the given
+ * resource.
+ *
+ * @throws CoreException
+ * if the store could not be obtained for any reason.
*/
- protected PropertyStore getPropertyStore(IResource target) throws CoreException {
+ private PropertyStore getPropertyStore(IResource target) throws CoreException {
try {
Resource host = getPropertyHost(target);
ResourceInfo info = host.getResourceInfo(false, false);
@@ -198,16 +190,16 @@
}
/**
- * Returns the property store to use when storing a property for the
- * given resource, or null if the store is not available.
+ * Returns the property store to use when storing a property for the given
+ * resource, or null if the store is not available.
*/
- protected PropertyStore getPropertyStoreOrNull(IResource target) {
+ private PropertyStore getPropertyStoreOrNull(IResource target) {
Resource host = getPropertyHost(target);
ResourceInfo info = host.getResourceInfo(false, false);
if (info != null) {
PropertyStore store = info.getPropertyStore();
if (store != null) {
- //sync on the store in case of concurrent deletion
+ // sync on the store in case of concurrent deletion
synchronized (store) {
if (store.isRunning())
return store;
@@ -217,12 +209,12 @@
return null;
}
- public void handleEvent(LifecycleEvent event) throws CoreException {
+ public synchronized void handleEvent(LifecycleEvent event) throws CoreException {
if (event.kind == LifecycleEvent.PRE_PROJECT_CLOSE)
closePropertyStore(event.resource);
}
- protected PropertyStore openPropertyStore(IResource target) {
+ private PropertyStore openPropertyStore(IResource target) {
int type = target.getType();
Assert.isTrue(type != IResource.FILE && type != IResource.FOLDER);
IPath location = workspace.getMetaArea().getPropertyStoreLocation(target);
@@ -233,24 +225,23 @@
return store;
}
- public void setProperty(IResource target, QualifiedName key, String value) throws CoreException {
+ public synchronized void setProperty(IResource target, QualifiedName key, String value) throws CoreException {
PropertyStore store = getPropertyStore(target);
- synchronized (store) {
- assertRunning(target, store);
- if (value == null) {
- store.remove(getPropertyKey(target), key);
- } else {
- StoredProperty prop = new StoredProperty(key, value);
- store.set(getPropertyKey(target), prop);
- }
- store.commit();
+ assertRunning(target, store);
+ if (value == null) {
+ store.remove(getPropertyKey(target), key);
+ } else {
+ StoredProperty prop = new StoredProperty(key, value);
+ store.set(getPropertyKey(target), prop);
}
+ store.commit();
}
- protected void setPropertyStore(IResource target, PropertyStore value) {
- // fetch the info but don't bother making it mutable even though we are going
- // to modify it. We don't know whether or not the tree is open and it really doesn't
- // matter as the change we are doing does not show up in deltas.
+ private void setPropertyStore(IResource target, PropertyStore value) {
+ // fetch the info but don't bother making it mutable even though we are
+ // going to modify it. We don't know whether or not the tree is open and
+ // it really doesn't matter as the change we are doing does not show up in
+ // deltas.
ResourceInfo info = getPropertyHost(target).getResourceInfo(false, false);
if (info.getType() == IResource.PROJECT)
((ProjectInfo) info).setPropertyStore(value);
@@ -258,11 +249,11 @@
((RootInfo) info).setPropertyStore(value);
}
- public void shutdown(IProgressMonitor monitor) throws CoreException {
+ public synchronized void shutdown(IProgressMonitor monitor) throws CoreException {
closePropertyStore(workspace.getRoot());
}
- public void startup(IProgressMonitor monitor) throws CoreException {
+ public synchronized void startup(IProgressMonitor monitor) throws CoreException {
workspace.addLifecycleListener(this);
}
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/TestingSupport.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/TestingSupport.java
deleted file mode 100644
index ff5d1b2..0000000
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/TestingSupport.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.properties;
-
-import org.eclipse.core.internal.resources.Resource;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * Provides special internal access to the property store implementation.
- * This class is to be used for testing purposes only.
- *
- * @since 2.1
- */
-public class TestingSupport {
-
- /**
- * Return the property store which is associated with the given resource.
- *
- * @param resource the resource whose property store is being accessed
- * @return the resource's property store
- * @throws CoreException if there was a problem accessing the resource's property store
- * @since 2.1
- */
- public static PropertyStore getPropertyStore(IResource resource) throws CoreException {
- return ((Resource) resource).getPropertyManager().getPropertyStore(resource);
- }
-
-}
\ No newline at end of file