[ 
https://issues.apache.org/jira/browse/FELIX-1832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12771996#action_12771996
 ] 

Felix Meschberger commented on FELIX-1832:
------------------------------------------

Some more flesh to the bone: The issue is that the framework calls the 
ServiceFactory.getService(Bundle, ServiceReference) method, which then tries to 
create the component, bind services and call the activate method. If this 
fails, the getService method will return null.

Before, the component was also deactivated in this case. Part of the 
deactivation is unregistration of the ServiceFactory. This is not allowed while 
the framework is calling the getService method. As a consequence the Felix 
framework throws an IllegalStateException leaving the service reference in an 
unclear state: In fact the service reference is not registered any more but the 
service registry still keeps some references to the ServiceFactory instance for 
some bundles.

This prevents the ServiceReference object from being GC-ed and thus also 
prevents the class loader from being collected. See also FELIX-1833

> ServiceFactory must not be deactivated if the instances fails to be created
> ---------------------------------------------------------------------------
>
>                 Key: FELIX-1832
>                 URL: https://issues.apache.org/jira/browse/FELIX-1832
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions: scr-1.2.0
>            Reporter: Felix Meschberger
>            Assignee: Felix Meschberger
>             Fix For: scr-1.2.0
>
>
> The AbstractComponentManager.Registered state (Satisfied state for delayed 
> and service factory components) class tries to deactivate the component if 
> the component instance cannot be created and setup. Part of this deactivation 
> is actually unregistration of the service factory service.
> This may fail if the getService method is called as part of a chain of 
> service activations, one of which is actually trying to get the service 
> instance from the factory. It is not allowed to unregister this exact service 
> in this situation.
> So, instead of deactivating the component, the component instance is just 
> deleted and the component remains in the registered state.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to