FELIX-4108 Deadlock in the new extender
* Use a ConcurrentHashMap to avoid synchronized blocks
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1490600 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
index 99a2ebe..daebcf3 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
@@ -32,6 +32,7 @@
import org.osgi.service.cm.ManagedServiceFactory;
import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
/**
* This class defines common mechanisms of iPOJO component factories
@@ -63,7 +64,7 @@
* The list of the managed instance managers.
* The key of this map is the name (i.e. instance names) of the created instance
*/
- protected final Map<String, ComponentInstance> m_componentInstances = new HashMap<String, ComponentInstance>();
+ protected final Map<String, ComponentInstance> m_componentInstances = new ConcurrentHashMap<String, ComponentInstance>();
/**
* The component type metadata.
@@ -421,9 +422,7 @@
* @return the component instance, {@literal null} if not found
*/
public ComponentInstance getInstanceByName(String name) {
- synchronized (this) {
- return m_componentInstances.get(name);
- }
+ return m_componentInstances.get(name);
}
/**
@@ -720,9 +719,7 @@
*/
public void disposed(ComponentInstance instance) {
String name = instance.getInstanceName();
- synchronized (this) {
- m_componentInstances.remove(name);
- }
+ m_componentInstances.remove(name);
INSTANCE_NAME.remove(name);
}