Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-5683

getServiceProperties returns null instead of empty dictionary

    XMLWordPrintableJSON

Details

    Description

      There are two issues:

      1)

      In the felix users mailing list (see [1]), Bram reported the following:

      when you set a component service properties like this:

      Component component = 
      m_dependencyManager.createComponent().setInterface(ApplicationService.class.getName(),new Properties());
      component.getServiceProperties().put("a", "b");
      

      then you get a NPE because the component.getServiceProperties() method returns null instead of the empty dictionary that has been set in the setInterfaceMethod.

      This is a regression made in r9 release, in the FELIX-5522 where a refactoring was done regarding aspect service properties.

      A fix can be made in order to behave like before (that is : avoid the NPE).

      2)

      Bram, I may be wrong but I think that one new issue is that the dictionary returned by the getServiceProperties() method was so far (since the initial version of felix dm 2.0.1) a copy of the service properties dictionary maintained in the ComponentImpl, so if you would like to do set service properties like this:

      Component component = m_dependencyManager.createComponent().setInterface(ApplicationService.class.getName(),new Properties());
      component.getServiceProperties().put("a", "b");
      m_dependencyManager.add(component);  // won't add "a=b" properties
      

      then the "a" property will be set in the copy of the internal dictionary returned by the getServiceProperties() method, and the "a=b" service properties won't be set when the component is added in the m_dependencyManager.

      So, if what I'm saying is correct and if you would like to see this new behavior implemented, please open a new jira issue and I will manage to implement it; thanks

      PS: I'm now fixing the 1) regression, in order to avoid the NPE.

      [1] http://www.mail-archive.com/users%40felix.apache.org/msg17939.html

      Attachments

        Activity

          People

            pderop Pierre De Rop
            pderop Pierre De Rop
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: