Unbind method in Service Reference Listener

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Unbind method in Service Reference Listener

Kim Theng Chong
Hi all,
I have some questions regarding on unbind method in service reference listener. 
Given that I have a service reference bean (which is optional) and there is a listener with bind/unbind method

<reference id=”serviceReference” interface=”my.serviceInterface”
              availability=”optional”>
      <reference-listener 
              bind-method=”bind” unbind-method=”unbind”>
          <bean class=“my.referenceListener”/>        
      </reference-listener>
   </reference-list>
and this is the unbind method
public void unbind(ServiceType service, Map properties){
   service.unregister(something); //hit NPE intermittently during start up
}
During Felix container start up, it will hit Null Pointer Exception intermittently (not all the time during start up) and it was thrown from the unbind method. 
From the debug mode, it will go into  unbind(null, null)in the AbstractServiceReferenceRecipe#updateListeners (I am using aries.blueprint.core V1.1.0)

protected void updateListeners() {
if (references.isEmpty()) { unbind(null, null); //(ServiceReference, Service) } else { retrack(); } }
If I not mistaken, in Spring DM, the unbind method will only be called if current backing service is unregistered, and no replacement service is immediately available, i.e.: previously there is something bind to it before it goes to unbind (Please correct me if I am wrong). Is this not the case for Aries blueprint? as in based on the code, there is possibility to unbind(null, null)? May I know under what circumstances this unbind(null, null) could happen?

Thank you.