Author: fmeschbe
Date: Fri Apr 16 14:38:52 2010
New Revision: 934927
URL: http://svn.apache.org/viewvc?rev=934927&view=rev
Log:
FELIX-2289 Synchronize all access to internal maps to prevent data structure
corruption
Modified:
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
Modified:
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
URL:
http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java?rev=934927&r1=934926&r2=934927&view=diff
==============================================================================
---
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
(original)
+++
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
Fri Apr 16 14:38:52 2010
@@ -119,7 +119,11 @@ public class ComponentFactoryImpl extend
throw new ComponentException( "Failed activating component" );
}
- m_componentInstances.put( cm, cm );
+ synchronized ( m_componentInstances )
+ {
+ m_componentInstances.put( cm, cm );
+ }
+
return instance;
}
@@ -231,9 +235,15 @@ public class ComponentFactoryImpl extend
}
else if ( m_isConfigurationFactory )
{
- if ( m_configuredServices != null )
+ Map configuredServices = m_configuredServices;
+ if ( configuredServices != null )
{
- ImmediateComponentManager cm = ( ImmediateComponentManager )
m_configuredServices.remove( pid );
+ ImmediateComponentManager cm;
+ synchronized ( configuredServices )
+ {
+ cm = ( ImmediateComponentManager )
configuredServices.remove( pid );
+ }
+
if ( cm != null )
{
log( LogService.LOG_DEBUG, "Disposing component after
configuration deletion", null );
@@ -259,13 +269,18 @@ public class ComponentFactoryImpl extend
else if ( m_isConfigurationFactory )
{
ImmediateComponentManager cm;
- if ( m_configuredServices != null )
+ Map configuredServices = m_configuredServices;
+ if ( configuredServices != null )
{
- cm = ( ImmediateComponentManager ) m_configuredServices.get(
pid );
+ synchronized ( configuredServices )
+ {
+ cm = ( ImmediateComponentManager ) configuredServices.get(
pid );
+ }
}
else
{
m_configuredServices = new HashMap();
+ configuredServices = m_configuredServices;
cm = null;
}
@@ -285,7 +300,10 @@ public class ComponentFactoryImpl extend
}
// keep a reference for future updates
- m_configuredServices.put( pid, cm );
+ synchronized ( configuredServices )
+ {
+ configuredServices.put( pid, cm );
+ }
}
else
@@ -336,7 +354,10 @@ public class ComponentFactoryImpl extend
cms[i].dispose( reason );
}
- m_componentInstances.clear();
+ synchronized ( m_componentInstances )
+ {
+ m_componentInstances.clear();
+ }
cms = getComponentManagers( m_configuredServices );
for ( int i = 0; i < cms.length; i++ )