Glenn Marcy created FELIX-3838:
----------------------------------

             Summary: [DS] Race condition in ImmediateComponentHolder
                 Key: FELIX-3838
                 URL: https://issues.apache.org/jira/browse/FELIX-3838
             Project: Felix
          Issue Type: Bug
          Components: Declarative Services (SCR)
    Affects Versions: scr-1.6.2
            Reporter: Glenn Marcy


There is a race condition where one thread is running the 
BundleComponentActivator
and calling enableComponents on the ImmediateComponentHolder when another thread
is running that has called configurationUpdated.  The first thread is executing
this:

        m_enabled = true;
        final ImmediateComponentManager[] cms = getComponentManagers( false );
        ...
            for ( ImmediateComponentManager cm : cms )
            {
                cm.enable( async );
            }

The second thread is executing this:

                // enable the component if it is initially enabled
                if ( m_enabled && getComponentMetadata().isEnabled() )
                {
                    newIcm.enable( false );
                    ...
                }

                // store the component in the map
                putComponentManager( pid, newIcm );

The failing sequence is this:

The second thread executes the test of m_enabled and it is false, so it will not
enable the component manager expecting that it will be enabled by 
enableComponents
later when it is called.  The first thread then sets m_enabled to true and gets 
a
copy of the entries in the map of component managers in order to enable them.  
The
second thread puts the component manager into that map, but after the first 
thread
has already made a copy of the managers in that map, so the component manager 
the
second thread created will not be enabled at all.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to