Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
org.apache.felix.dependencymanager-r1
-
None
Description
During the implementation of FELIX-5336 (support for prototype scopes), I came across the following problem:
1) you create a Consumer component:
dm.add(consumer):
2) the consumer depends on some services providers, so you add two providers:
dm.add(p1);
dm.add(p2);
3) you remove the consumer:
dm.remove(consumer);
at this point, the consumer is unbound from the two providers because the consumer is being stopped, but the bug is the following: when the handleRemoved method is called, the events are not removed from the m_dependencyEvents collection because the m_isStarted flag is set to true, so the two dependencies remains:
private void handleRemoved(DependencyContext dc, Event e) { try { if (! m_isStarted) { return; }
4) now, you remove the two providers
5) you re-add the consumer and the two providers:
dm.add(consumer);
dm.add(p3);
dm.add(p4);
but when the consumer is re-added, it gets injected with the previous dependency events (the two previous p1,p2), and this is wrong of course.