Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2004-11-01 22:18:40 +0000
committerJohn Arthorne2004-11-01 22:18:40 +0000
commit5b0858489222b0f55dcc2ca7b3f74720ca11d97b (patch)
tree36f5e7462640dc241ab67e7a31f613bab6822b79
parent1e52ee008d3987cc2487f5f59eee44b0d310fc05 (diff)
downloadeclipse.platform.runtime-5b0858489222b0f55dcc2ca7b3f74720ca11d97b.tar.gz
eclipse.platform.runtime-5b0858489222b0f55dcc2ca7b3f74720ca11d97b.tar.xz
eclipse.platform.runtime-5b0858489222b0f55dcc2ca7b3f74720ca11d97b.zip
Back out of fix for bug 76779v20041101Root_Registry_reorg_31
-rw-r--r--bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/EclipsePreferences.java50
-rw-r--r--bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/ExportedPreferences.java4
2 files changed, 27 insertions, 27 deletions
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/EclipsePreferences.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/EclipsePreferences.java
index d50809e10..b48edfab5 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/EclipsePreferences.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/EclipsePreferences.java
@@ -94,15 +94,11 @@ public class EclipsePreferences implements IEclipsePreferences, IScope {
toVisit[i].accept(visitor);
}
- /**
- * Adds and returns a new child
- */
- protected synchronized IEclipsePreferences addChild(String childName, IEclipsePreferences child) {
+ protected synchronized void addChild(String childName, IEclipsePreferences child) {
//Thread safety: synchronize method to protect modification of children field
if (children == null)
children = Collections.synchronizedMap(new HashMap());
children.put(childName, child == null ? (Object) childName : child);
- return child;
}
/*
@@ -277,6 +273,7 @@ public class EclipsePreferences implements IEclipsePreferences, IScope {
public IEclipsePreferences create(IEclipsePreferences nodeParent, String nodeName, Plugin context) {
EclipsePreferences result = internalCreate(nodeParent, nodeName, context);
+ ((EclipsePreferences) nodeParent).addChild(nodeName, result);
IEclipsePreferences loadLevel = result.getLoadLevel();
// if this node or a parent node is not the load level then return
@@ -376,21 +373,21 @@ public class EclipsePreferences implements IEclipsePreferences, IScope {
* Thread safe way to obtain a child for a given key. Returns the child
* that matches the given key, or null if there is no matching child
*/
- protected IEclipsePreferences getChild(String key, Plugin context, boolean create) {
- synchronized (this) {
- if (children == null)
- return null;
- Object value = children.get(key);
- if (value == null)
- return null;
- if (value instanceof IEclipsePreferences)
- return (IEclipsePreferences) value;
- // if we aren't supposed to create this node, then
- // just return null
- if (!create)
- return null;
- }
- return addChild(key, create(this, key, context));
+ protected synchronized IEclipsePreferences getChild(String key, Plugin context, boolean create) {
+ if (children == null)
+ return null;
+ Object value = children.get(key);
+ if (value == null)
+ return null;
+ if (value instanceof IEclipsePreferences)
+ return (IEclipsePreferences) value;
+ // if we aren't supposed to create this node, then
+ // just return null
+ if (!create)
+ return null;
+ value = create(this, key, context);
+ addChild(key, (IEclipsePreferences) value);
+ return (IEclipsePreferences) value;
}
/**
@@ -526,12 +523,13 @@ public class EclipsePreferences implements IEclipsePreferences, IScope {
int index = path.indexOf(IPath.SEPARATOR);
String key = index == -1 ? path : path.substring(0, index);
boolean added = false;
- IEclipsePreferences child = getChild(key, context, true);
- if (child == null) {
- //note that in case of race condition, node may be initialized twice
- child = create(this, key, context);
- addChild(key, child);
- added = true;
+ IEclipsePreferences child;
+ synchronized (this) {
+ child = getChild(key, context, true);
+ if (child == null) {
+ child = create(this, key, context);
+ added = true;
+ }
}
// notify listeners if a child was added
if (added && notify)
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/ExportedPreferences.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/ExportedPreferences.java
index 8cf2e98c8..ee74878e0 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/ExportedPreferences.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/ExportedPreferences.java
@@ -62,7 +62,9 @@ public class ExportedPreferences extends EclipsePreferences implements IExported
* @see org.eclipse.core.runtime.preferences.IScope#create(org.eclipse.core.runtime.preferences.IEclipsePreferences, java.lang.String)
*/
public IEclipsePreferences create(IEclipsePreferences nodeParent, String nodeName, Plugin context) {
- return addChild(nodeName, new ExportedPreferences(nodeParent, nodeName));
+ IEclipsePreferences result = new ExportedPreferences(nodeParent, nodeName);
+ addChild(nodeName, result);
+ return result;
}
/*

Back to the top