Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBJ Hargrave2017-01-13 12:19:05 -0500
committerThomas Watson2017-01-18 12:05:46 -0500
commitaeb74d9f60b14d98eb9eb3762b1a48a6c8d6bb75 (patch)
tree8715bb0eae662cd03933b236c8a6c236882c71a5
parent4cc1e875a99cc7d7ea2abe0d76506806b13ff641 (diff)
downloadrt.equinox.framework-aeb74d9f60b14d98eb9eb3762b1a48a6c8d6bb75.tar.gz
rt.equinox.framework-aeb74d9f60b14d98eb9eb3762b1a48a6c8d6bb75.tar.xz
rt.equinox.framework-aeb74d9f60b14d98eb9eb3762b1a48a6c8d6bb75.zip
Bug 510641 - Covert use of Headers to CaseInsensitiveDictionaryMap
Change-Id: If786a84bf13039cf92204dad8b0afe4abc75c9af Signed-off-by: BJ Hargrave <hargrave@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/OSGiCapabilityTest.java9
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java9
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java11
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java18
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/ManifestLocalization.java21
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/SystemBundleFile.java8
6 files changed, 41 insertions, 35 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/OSGiCapabilityTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/OSGiCapabilityTest.java
index f880ad346..376f59237 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/OSGiCapabilityTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/OSGiCapabilityTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2012 IBM Corporation and others.
+ * Copyright (c) 2010, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,8 +16,9 @@ import java.net.URL;
import java.util.*;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.osgi.framework.util.Headers;
+import org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap;
import org.eclipse.osgi.service.resolver.*;
+import org.eclipse.osgi.util.ManifestElement;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.framework.namespace.IdentityNamespace;
@@ -40,7 +41,9 @@ public class OSGiCapabilityTest extends AbstractStateTest {
private Dictionary loadManifest(String manifest) {
URL url = getContext().getBundle().getEntry(MANIFEST_ROOT + manifest);
try {
- return Headers.parseManifest(url.openStream());
+ CaseInsensitiveDictionaryMap<String, String> headers = new CaseInsensitiveDictionaryMap<String, String>();
+ ManifestElement.parseBundleManifest(url.openStream(), headers);
+ return headers.asUnmodifiableDictionary();
} catch (IOException e) {
fail("Unexpected error loading manifest: " + manifest, e);
} catch (BundleException e) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java
index 3aaa4ecdb..c244b40b3 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2015 IBM Corporation and others.
+ * Copyright (c) 2003, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,9 +16,10 @@ import java.net.URL;
import java.util.*;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.osgi.framework.util.Headers;
+import org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap;
import org.eclipse.osgi.service.resolver.*;
import org.eclipse.osgi.tests.OSGiTestsActivator;
+import org.eclipse.osgi.util.ManifestElement;
import org.osgi.framework.*;
import org.osgi.framework.namespace.IdentityNamespace;
import org.osgi.framework.wiring.*;
@@ -3714,7 +3715,9 @@ public class StateResolverTest extends AbstractStateTest {
private Dictionary loadManifest(String manifest) {
URL url = getContext().getBundle().getEntry(MANIFEST_ROOT + manifest);
try {
- return Headers.parseManifest(url.openStream());
+ CaseInsensitiveDictionaryMap<String, String> headers = new CaseInsensitiveDictionaryMap<String, String>();
+ ManifestElement.parseBundleManifest(url.openStream(), headers);
+ return headers.asUnmodifiableDictionary();
} catch (IOException e) {
fail("Unexpected error loading manifest: " + manifest, e);
} catch (BundleException e) {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java
index 7a2f5a1e0..34ce4e049 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2016 IBM Corporation and others.
+ * Copyright (c) 2003, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,7 +15,7 @@ import java.lang.reflect.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
-import org.eclipse.osgi.framework.util.Headers;
+import org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap;
import org.eclipse.osgi.internal.debug.Debug;
import org.eclipse.osgi.internal.messages.Msg;
import org.eclipse.osgi.internal.serviceregistry.ServiceReferenceImpl;
@@ -179,11 +179,10 @@ public class FilterImpl implements Filter /* since Framework 1.1 */ {
* variants of the same key name.
*/
public boolean match(Dictionary<String, ?> dictionary) {
- if (dictionary != null) {
- dictionary = new Headers<>(dictionary);
+ if (dictionary == null) {
+ return matches(null);
}
-
- return matchCase(dictionary);
+ return matches(new CaseInsensitiveDictionaryMap<>(dictionary));
}
/**
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java
index 9a569bfbf..5cda709d7 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2016 IBM Corporation and others.
+ * Copyright (c) 2012, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,7 +19,7 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.osgi.container.*;
import org.eclipse.osgi.container.ModuleContainerAdaptor.ModuleEvent;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
-import org.eclipse.osgi.framework.util.Headers;
+import org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap;
import org.eclipse.osgi.internal.container.LockSet;
import org.eclipse.osgi.internal.debug.Debug;
import org.eclipse.osgi.internal.framework.EquinoxConfiguration;
@@ -31,6 +31,7 @@ import org.eclipse.osgi.storage.bundlefile.BundleEntry;
import org.eclipse.osgi.storage.bundlefile.BundleFile;
import org.eclipse.osgi.storage.url.BundleResourceHandler;
import org.eclipse.osgi.storage.url.bundleentry.Handler;
+import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleException;
@@ -46,7 +47,7 @@ public final class BundleInfo {
private boolean isReference;
private boolean hasPackageInfo;
private BundleFile bundleFile;
- private Headers<String, String> rawHeaders;
+ private Map<String, String> rawHeaders;
private ModuleRevision revision;
private ManifestLocalization headerLocalization;
private ProtectionDomain domain;
@@ -98,16 +99,15 @@ public final class BundleInfo {
return cachedHeaders;
}
- Headers<String, String> getRawHeaders() {
+ Map<String, String> getRawHeaders() {
synchronized (genMonitor) {
if (rawHeaders == null) {
BundleEntry manifest = getBundleFile().getEntry(OSGI_BUNDLE_MANIFEST);
if (manifest == null) {
- rawHeaders = new Headers<>(0);
- rawHeaders.setReadOnly();
+ rawHeaders = Collections.emptyMap();
} else {
try {
- rawHeaders = Headers.parseManifest(manifest.getInputStream());
+ rawHeaders = Collections.unmodifiableMap(ManifestElement.parseBundleManifest(manifest.getInputStream(), new CaseInsensitiveDictionaryMap<String, String>()));
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
@@ -516,7 +516,7 @@ public final class BundleInfo {
@Override
public Enumeration<String> elements() {
- return generation.getRawHeaders().elements();
+ return Collections.enumeration(generation.getRawHeaders().values());
}
@Override
@@ -537,7 +537,7 @@ public final class BundleInfo {
@Override
public Enumeration<String> keys() {
- return generation.getRawHeaders().keys();
+ return Collections.enumeration(generation.getRawHeaders().keySet());
}
@Override
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/ManifestLocalization.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/ManifestLocalization.java
index a67ec5309..7fc5223ce 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/ManifestLocalization.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/ManifestLocalization.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2016 IBM Corporation and others.
+ * Copyright (c) 2004, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,8 +14,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.*;
+import java.util.Map.Entry;
import org.eclipse.osgi.container.*;
-import org.eclipse.osgi.framework.util.Headers;
+import org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap;
import org.eclipse.osgi.storage.BundleInfo.Generation;
import org.osgi.framework.Constants;
import org.osgi.framework.namespace.HostNamespace;
@@ -61,11 +62,9 @@ public class ManifestLocalization {
return rawHeaders;
}
ResourceBundle localeProperties = getResourceBundle(localeString, isDefaultLocale);
- Enumeration<String> eKeys = this.rawHeaders.keys();
- Headers<String, String> localeHeaders = new Headers<>(this.rawHeaders.size());
- while (eKeys.hasMoreElements()) {
- String key = eKeys.nextElement();
- String value = this.rawHeaders.get(key);
+ CaseInsensitiveDictionaryMap<String, String> localeHeaders = new CaseInsensitiveDictionaryMap<>(this.rawHeaders);
+ for (Entry<String, String> entry : localeHeaders.entrySet()) {
+ String value = entry.getValue();
if (value.startsWith("%") && (value.length() > 1)) { //$NON-NLS-1$
String propertiesKey = value.substring(1);
try {
@@ -73,14 +72,14 @@ public class ManifestLocalization {
} catch (MissingResourceException ex) {
value = propertiesKey;
}
+ entry.setValue(value);
}
- localeHeaders.set(key, value);
}
- localeHeaders.setReadOnly();
+ Dictionary<String, String> result = localeHeaders.asUnmodifiableDictionary();
if (isDefaultLocale) {
- defaultLocaleHeaders = localeHeaders;
+ defaultLocaleHeaders = result;
}
- return (localeHeaders);
+ return result;
}
private String[] buildNLVariants(String nl) {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/SystemBundleFile.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/SystemBundleFile.java
index 002ab3739..e2bf89c9c 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/SystemBundleFile.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/SystemBundleFile.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
+ * Copyright (c) 2013, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,9 +13,11 @@ package org.eclipse.osgi.storage;
import java.io.*;
import java.net.URL;
import java.util.Enumeration;
-import org.eclipse.osgi.framework.util.Headers;
+import java.util.Map;
+import org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap;
import org.eclipse.osgi.storage.bundlefile.BundleEntry;
import org.eclipse.osgi.storage.bundlefile.BundleFile;
+import org.eclipse.osgi.util.ManifestElement;
import org.osgi.framework.BundleException;
public class SystemBundleFile extends BundleFile {
@@ -91,7 +93,7 @@ public class SystemBundleFile extends BundleFile {
URL url = manifests.nextElement();
try {
// check each manifest until we find one with the Eclipse-SystemBundle: true header
- Headers<String, String> headers = Headers.parseManifest(url.openStream());
+ Map<String, String> headers = ManifestElement.parseBundleManifest(url.openStream(), new CaseInsensitiveDictionaryMap<String, String>());
if ("true".equals(headers.get(Storage.ECLIPSE_SYSTEMBUNDLE))) //$NON-NLS-1$
return url;
} catch (BundleException e) {

Back to the top