Modify StringMap to make sure all keys are strings. (FELIX-3852)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1441018 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/BundleImpl.java b/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
index 79b709c..b2cc828 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
@@ -337,7 +337,7 @@
// Spec says empty local returns raw headers.
if (locale.length() == 0)
{
- result = new StringMap(adapt(BundleRevisionImpl.class).getHeaders(), false);
+ result = new StringMap(adapt(BundleRevisionImpl.class).getHeaders());
}
// If we have no result, try to get it from the cached headers.
@@ -373,7 +373,7 @@
if (result == null)
{
// Get a modifiable copy of the raw headers.
- Map headers = new StringMap(adapt(BundleRevisionImpl.class).getHeaders(), false);
+ Map headers = new StringMap(adapt(BundleRevisionImpl.class).getHeaders());
// Assume for now that this will be the result.
result = headers;
diff --git a/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java b/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
index 2bc580b..3d774dd 100644
--- a/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
+++ b/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
@@ -120,7 +120,7 @@
private final Logger m_logger;
private final Map m_configMap;
- private final Map m_headerMap = new StringMap(false);
+ private final Map m_headerMap = new StringMap();
private final BundleRevision m_systemBundleRevision;
private volatile List<BundleCapability> m_capabilities = Collections.EMPTY_LIST;
private volatile Set<String> m_exportNames = Collections.EMPTY_SET;
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index ffff6e8..c3650b9 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -305,7 +305,7 @@
{
super();
// Copy the configuration properties; convert keys to strings.
- m_configMutableMap = new StringMap(false);
+ m_configMutableMap = new StringMap();
if (configMap != null)
{
for (Iterator i = configMap.entrySet().iterator(); i.hasNext(); )
@@ -783,7 +783,7 @@
// its bundle context to the logger so that it can track log services.
m_logger.setSystemBundleContext(_getBundleContext());
- // We have to check with the security provider (if there is one).
+ // We have to check with the security provider (if there is one).
// This is to avoid having bundles in the cache that have been tampered with
SecurityProvider sp = getFramework().getSecurityProvider();
if ((sp != null) && (System.getSecurityManager() != null))
@@ -829,7 +829,7 @@
releaseGlobalLock();
}
}
-
+
// Clear the cache of classes coming from the system bundle.
// This is only used for Felix.getBundle(Class clazz) to speed
// up class lookup for the system bundle.
diff --git a/framework/src/main/java/org/apache/felix/framework/FilterImpl.java b/framework/src/main/java/org/apache/felix/framework/FilterImpl.java
index 3f1cc2d..666533f 100644
--- a/framework/src/main/java/org/apache/felix/framework/FilterImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/FilterImpl.java
@@ -113,7 +113,7 @@
public WrapperCapability(ServiceReference sr)
{
super(null, null, Collections.EMPTY_MAP, Collections.EMPTY_MAP);
- m_map = new StringMap(false);
+ m_map = new StringMap();
for (String key : sr.getPropertyKeys())
{
m_map.put(key, sr.getProperty(key));
@@ -161,7 +161,7 @@
if (!caseSensitive)
{
m_dict = null;
- m_map = new StringMap(false);
+ m_map = new StringMap();
if (dict != null)
{
Enumeration keys = dict.keys();
diff --git a/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java b/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
index be6fb4b..b41d900 100644
--- a/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
@@ -47,7 +47,7 @@
// Service factory interface.
private volatile ServiceFactory m_factory;
// Associated property dictionary.
- private volatile Map m_propMap = new StringMap(false);
+ private volatile Map m_propMap = new StringMap();
// Re-usable service reference.
private final ServiceReferenceImpl m_ref;
// Flag indicating that we are unregistering.
@@ -272,7 +272,7 @@
private void initializeProperties(Dictionary dict)
{
// Create a case-insensitive map for the properties.
- Map props = new StringMap(false);
+ Map props = new StringMap();
if (dict != null)
{
diff --git a/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java b/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java
index c1269c0..baebe1d 100644
--- a/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java
+++ b/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java
@@ -89,7 +89,7 @@
// Get manifest.
Manifest mf = new Manifest(is);
// Create a case insensitive map of manifest attributes.
- return new StringMap(mf.getMainAttributes(), false);
+ return new StringMap(mf.getMainAttributes());
}
finally
{
diff --git a/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java b/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
index 7a539da..99d9679 100644
--- a/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
+++ b/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
@@ -99,7 +99,7 @@
public Map getManifestHeader() throws Exception
{
// Create a case insensitive map of manifest attributes.
- Map headers = new StringMap(false);
+ Map headers = new StringMap();
// Read and parse headers.
getMainAttributes(headers, m_zipFile);
return headers;
diff --git a/framework/src/main/java/org/apache/felix/framework/util/StringMap.java b/framework/src/main/java/org/apache/felix/framework/util/StringMap.java
index 9481b0e..39c2eb6 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/StringMap.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/StringMap.java
@@ -34,15 +34,17 @@
private final TreeMap<char[], KeyValueEntry> m_map = new TreeMap<char[], KeyValueEntry>(COMPARATOR);
- public StringMap(boolean caseSensitive)
+ public StringMap()
{
}
- public StringMap(Map map, boolean caseSensitive)
+ public StringMap(Map<? extends Object, ? extends Object> map)
{
- for (Entry e : (Set<Entry>)map.entrySet())
+ for (Map.Entry<? extends Object, ? extends Object> e : map.entrySet())
{
- put(e.getKey().toString(), e.getValue());
+ KeyValueEntry kve = (KeyValueEntry) m_map.put(
+ toUpperCase(e.getKey().toString()),
+ new KeyValueEntry(e.getKey().toString(), e.getValue()));
}
}
@@ -85,6 +87,15 @@
}
@Override
+ public void putAll(Map<? extends String, ? extends Object> map)
+ {
+ for (Map.Entry<? extends String, ? extends Object> e : map.entrySet())
+ {
+ put(e.getKey().toString(), e.getValue());
+ }
+ }
+
+ @Override
public Object remove(Object arg0)
{
KeyValueEntry kve = m_map.remove(toUpperCase(arg0.toString()));
@@ -203,4 +214,4 @@
String key;
Object value;
}
-}
\ No newline at end of file
+}