Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java')
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java
index 236ad75d7..a16ea2c25 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkUtil.java
@@ -983,11 +983,23 @@ public class FrameworkUtil {
@SuppressWarnings("unchecked")
MapAsDictionary(Map< ? extends K, ? extends V> map) {
this.map = (Map<K,V>) requireNonNull(map);
- if (map.containsKey(null)) {
+ boolean nullKey;
+ try {
+ nullKey = map.containsKey(null);
+ } catch (NullPointerException e) {
+ nullKey = false; // map does not allow null key
+ }
+ if (nullKey) {
throw new NullPointerException(
"a Dictionary cannot contain a null key");
}
- if (map.containsValue(null)) {
+ boolean nullValue;
+ try {
+ nullValue = map.containsValue(null);
+ } catch (NullPointerException e) {
+ nullValue = false; // map does not allow null value
+ }
+ if (nullValue) {
throw new NullPointerException(
"a Dictionary cannot contain a null value");
}

Back to the top