Autogenerated unbind method may incorrectly drop service
--------------------------------------------------------

                 Key: FELIX-367
                 URL: https://issues.apache.org/jira/browse/FELIX-367
             Project: Felix
          Issue Type: Bug
          Components: Maven SCR Plugin
            Reporter: Felix Meschberger
            Assignee: Carsten Ziegeler


The SCR plugin may generate an unbind method for references with unary 
cardinality if no such method is available in the component class. The 
implementation of this method just sets the internal field to null.

According to the Declarative Services Specification, section 112.5.10, Bound 
Service Replacement, the replacement of a service reference with unary 
cardinality occurrs in the following order:

   1. the new (replacement) service is bound by calling the bind method
   2. the old (outgoing) service is unbound by calling the unbind method

In the case of the current implementation unbinding the old (outgoing) service 
will actually drop the new (replacement) service. A simple fix to this issue is 
to check whether the service being unbound is actually the one currently bound, 
hence

    private <Type> <name>
    protected void unbind<Name>(<Type> <name>) {
        if (this.<name> == <name>) {
            this.<name> = null;
        }
    }

This is not currently an issue but become an issue when fixing FELIX-366.

-- 
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