You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Dario Cimafonte <da...@travcorpuk.com> on 2015/12/07 13:29:23 UTC

Minor code smell in KubernetsDiscoveryServiceFactory

Hi all,

I was browsing the source code here (cellar-kubernetes):
https://github.com/apache/karaf-cellar/blob/master/kubernetes/src/main/java/org/apache/karaf/cellar/kubernetes/KubernetesDiscoveryServiceFactory.java#L69

This loop looks "idempotent" to me:
                Properties serviceProperties = new Properties();
                for (Map.Entry entry : serviceProperties.entrySet()) {
                    Object key = entry.getKey();
                    Object value = entry.getValue();
                    serviceProperties.put(key, value);
                }

I guess we want to loop over "properties" instead of "serviceProperties", to comply with this best practice:
"As a convention, it is recommended that when a Managed Service is updated, it should copy all the properties it does not recognize into the service registration properties. This will allow the Configuration Admin service to set properties on services which can then be used by other applications."

outlined here http://felix.apache.org/apidocs/configadmin/1.2.4/org/osgi/service/cm/ManagedService.html ?

Kind regards,
Dario

Re: Minor code smell in KubernetsDiscoveryServiceFactory

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Dario,

you are right, let me create a Jira and fix that.

Thanks,
Regards
JB

On 12/07/2015 01:29 PM, Dario Cimafonte wrote:
> Hi all,
>
> I was browsing the source code here (cellar-kubernetes):
>
> https://github.com/apache/karaf-cellar/blob/master/kubernetes/src/main/java/org/apache/karaf/cellar/kubernetes/KubernetesDiscoveryServiceFactory.java#L69
>
> This loop looks “idempotent” to me:
>
>                  Properties serviceProperties = new Properties();
>
>                  for (Map.Entry entry : serviceProperties.entrySet()) {
>
>                      Object key = entry.getKey();
>
>                      Object value = entry.getValue();
>
>                      serviceProperties.put(key, value);
>
>                  }
>
> I guess we want to loop over “properties” instead of
> “serviceProperties”, to comply with this best practice:
>
> “As a convention, it is recommended that when a Managed Service is
> updated, it should copy all the properties it does not recognize into
> the service registration properties. This will allow the Configuration
> Admin service to set properties on services which can then be used by
> other applications.”
>
> outlined here
> http://felix.apache.org/apidocs/configadmin/1.2.4/org/osgi/service/cm/ManagedService.html
> ?
>
> Kind regards,
>
> Dario
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com