Fixed some synchronization issues when accesses properties.
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@520015 13f79535-47bb-0310-9956-ffa450edef68
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 9e7e3b3..2c67dc8 100644
--- a/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
@@ -41,7 +41,7 @@
// Service factory interface.
private ServiceFactory m_factory = null;
// Associated property dictionary.
- private Map m_propMap = null;
+ private Map m_propMap = new StringMap(false);
// Re-usable service reference.
private ServiceReferenceImpl m_ref = null;
@@ -153,7 +153,7 @@
protected String[] getPropertyKeys()
{
- synchronized (m_list)
+ synchronized (m_propMap)
{
m_list.clear();
Iterator i = m_propMap.entrySet().iterator();
@@ -230,29 +230,24 @@
private void initializeProperties(Dictionary dict)
{
- // Create a case insensitive map.
- if (m_propMap == null)
- {
- m_propMap = new StringMap(false);
- }
- else
+ synchronized (m_propMap)
{
m_propMap.clear();
- }
-
- if (dict != null)
- {
- Enumeration keys = dict.keys();
- while (keys.hasMoreElements())
+
+ if (dict != null)
{
- Object key = keys.nextElement();
- m_propMap.put(key, dict.get(key));
+ Enumeration keys = dict.keys();
+ while (keys.hasMoreElements())
+ {
+ Object key = keys.nextElement();
+ m_propMap.put(key, dict.get(key));
+ }
}
+
+ // Add the framework assigned properties.
+ m_propMap.put(Constants.OBJECTCLASS, m_classes);
+ m_propMap.put(Constants.SERVICE_ID, m_serviceId);
}
-
- // Add the framework assigned properties.
- m_propMap.put(Constants.OBJECTCLASS, m_classes);
- m_propMap.put(Constants.SERVICE_ID, m_serviceId);
}
private Object getFactoryUnchecked(Bundle bundle)