diff options
author | Thomas Watson | 2014-08-07 18:12:24 +0000 |
---|---|---|
committer | Thomas Watson | 2014-08-07 19:40:15 +0000 |
commit | 6518be6daad51538b7124f49a889a4a762b63a07 (patch) | |
tree | 14e20eece00f885192c1f5e0706a8f81c7ea94b8 | |
parent | 2c2478f593605b9c4e1c34a7e1ec71f2740a7162 (diff) | |
download | rt.equinox.framework-6518be6daad51538b7124f49a889a4a762b63a07.tar.gz rt.equinox.framework-6518be6daad51538b7124f49a889a4a762b63a07.tar.xz rt.equinox.framework-6518be6daad51538b7124f49a889a4a762b63a07.zip |
Bug 441377 - Fix for null configuration valueI20140812-0800
Change-Id: I9d580a53ebd1bdd607ee3da30a87bfe4d4e1b480
-rw-r--r-- | bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java index dc036cd20..b918038c2 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java @@ -191,13 +191,26 @@ public class EquinoxConfiguration implements EnvironmentInfo { private final static Collection<String> populateInitConfig = Arrays.asList(PROP_OSGI_ARCH, PROP_OSGI_OS, PROP_OSGI_WS, PROP_OSGI_NL, FRAMEWORK_OS_NAME, FRAMEWORK_OS_VERSION, FRAMEWORK_PROCESSOR, FRAMEWORK_LANGUAGE); + private final static Object NULL_CONFIG = new Object() { + public String toString() { + return "null"; //$NON-NLS-1$ + } + }; + EquinoxConfiguration(Map<String, ?> initialConfiguration, HookRegistry hookRegistry) { this.initialConfig = initialConfiguration == null ? new HashMap<String, Object>(0) : new HashMap<String, Object>(initialConfiguration); this.hookRegistry = hookRegistry; Object useSystemPropsValue = initialConfig.get(PROP_USE_SYSTEM_PROPERTIES); boolean useSystemProps = useSystemPropsValue == null ? false : Boolean.parseBoolean(useSystemPropsValue.toString()); this.configuration = useSystemProps ? System.getProperties() : new Properties(); - this.configuration.putAll(initialConfig); + // do this the hard way to handle null values + for (Map.Entry<String, ?> initialEntry : initialConfiguration.entrySet()) { + if (initialEntry.getValue() == null) { + this.configuration.put(initialEntry.getKey(), NULL_CONFIG); + } else { + this.configuration.put(initialEntry.getKey(), initialEntry.getValue()); + } + } initializeProperties(this.configuration, aliasMapper); for (String initialKey : populateInitConfig) { @@ -429,18 +442,22 @@ public class EquinoxConfiguration implements EnvironmentInfo { public String clearConfiguration(String key) { Object result = configuration.remove(key); + configuration.put(key, NULL_CONFIG); return result instanceof String ? (String) result : null; } public Map<String, String> getConfiguration() { - Map<String, String> result = new HashMap<String, String>(configuration.size()); - for (Object key : configuration.keySet()) { - if (key instanceof String) { - String skey = (String) key; - result.put(skey, configuration.getProperty(skey)); + // must sync on configuration to avoid concurrent modification exception + synchronized (configuration) { + Map<String, String> result = new HashMap<String, String>(configuration.size()); + for (Object key : configuration.keySet()) { + if (key instanceof String) { + String skey = (String) key; + result.put(skey, configuration.getProperty(skey)); + } } + return result; } - return result; } public Debug getDebug() { @@ -458,7 +475,7 @@ public class EquinoxConfiguration implements EnvironmentInfo { @Override public String getProperty(String key) { String result = getConfiguration(key); - return result == null ? System.getProperty(key) : result; + return result == null && !this.configuration.containsKey(key) ? System.getProperty(key) : result; } @Override |