Pierre De Rop created FELIX-6891:
------------------------------------

             Summary: DM filter indices call getService on every service, 
activating SCR delayed components
                 Key: FELIX-6891
                 URL: https://issues.apache.org/jira/browse/FELIX-6891
             Project: Felix
          Issue Type: Improvement
          Components: Dependency Manager
            Reporter: Pierre De Rop
            Assignee: Pierre De Rop


When a filter index is enabled in DependencyManager (multi-property, aspect or 
adapter index), the index opens a {{ServiceTracker}} on {{(objectClass=*)}} 
with {{trackAllServices=true}}. In {{addingService}}, it calls 
{{BundleContext.getService(reference)}} for every service registered in the 
framework, although the returned service object is never used (the indices only 
manipulate {{ServiceReference}}s).

Affected classes:
- {{MultiPropertyFilterIndex}}
- {{AspectFilterIndex}}
- {{AdapterFilterIndex}}

As a consequence:
- The usage count of every service is incremented for the DependencyManager 
bundle, and never released as long as the service is registered.
- Delayed SCR components (and any lazy {{ServiceFactory}}) are activated as 
soon as they are registered, and can no longer be deactivated by SCR since 
their usage count stays positive.
- Every {{ServiceFactory}} creates an instance for the DependencyManager bundle.

Enabling an optional optimization therefore changes the behavior of the whole 
system.

h3. Example

Enable a filter index, for example through the 
{{org.apache.felix.dependencymanager.filterindex}} configuration.

Deploy a bundle with an SCR delayed component that provides a service, with no 
consumer.

Observe that the component is activated right after its service is registered, 
although nobody requested the service.

h3. Expected behavior

Enabling a filter index must not call {{getService}} on services it does not 
consume. Delayed SCR components must stay lazy, and service factories must not 
be invoked on behalf of the DependencyManager bundle because of the indices.




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

Reply via email to