Pierre De Rop created FELIX-6895:
------------------------------------

             Summary: ComponentScheduler: removed component can still be 
started by bind()
                 Key: FELIX-6895
                 URL: https://issues.apache.org/jira/browse/FELIX-6895
             Project: Felix
          Issue Type: Bug
          Components: Dependency Manager
            Reporter: Pierre De Rop
            Assignee: Pierre De Rop


When the {{org.apache.felix.dependencymanager.parallel}} property is set, 
components matching it are not started immediately by 
{{ComponentScheduler.add()}}. They are queued in {{m_pending}} until a 
{{ComponentExecutorFactory}} service becomes available. Both the queuing in 
{{add()}} and the flush in {{bind()}} run in the {{m_serial}} executor.

{{remove()}} is not run in {{m_serial}}. It runs directly in the caller thread, 
so it can interleave with {{bind()}}.

{code:java}
// bind(), running in m_serial
for (Component c : m_pending.keySet()) {
    createComponentExecutor(m_componentExecutorFactory, c);
    ((ComponentContext) c).start();
}
m_pending.clear();

// remove(), running in the caller thread
m_pending.remove(c);
((ComponentContext) c).stop();
{code}

h3. Example

The {{parallel}} property is set and component {{C}} is queued in 
{{m_pending}}, waiting for a {{ComponentExecutorFactory}}.

A {{ComponentExecutorFactory}} service is registered. {{bind()}} starts and its 
loop has already obtained {{C}} from {{m_pending}}.

Concurrently, the bundle owning {{C}} is stopped and {{remove(C)}} is called. 
{{m_pending.remove(C)}} has no effect on the running loop, and {{C.stop()}} 
does nothing because {{C}} was never started.

The loop in {{bind()}} continues and calls {{C.start()}}.

h3. Actual behavior

Component {{C}} is started after it has been removed. It stays active while its 
bundle is stopping or stopped, and nothing will stop it afterwards.

h3. Expected behavior

A component that has been removed is never started afterwards, whatever the 
timing between {{remove()}} and the arrival of a {{ComponentExecutorFactory}}.

h3. Affected code

- {{org.apache.felix.dependencymanager}}: 
{{org.apache.felix.dm.impl.ComponentScheduler}} ({{bind()}}, {{add()}}, 
{{remove()}})



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to