[ https://issues.apache.org/jira/browse/FELIX-6258?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tuan updated FELIX-6258: ------------------------ Description: Hi Felix devs, I'm using karaf 4.2.7 which include felix util 1.11.2 There is an interface *org.osgi.resource.Capability* with these methods {code:java} /** * Compares this {@code Capability} to another {@code Capability}. * * <p> * This {@code Capability} is equal to another {@code Capability} if they * have the same namespace, directives and attributes and are declared by * the same resource. * * @param obj The object to compare against this {@code Capability}. * @return {@code true} if this {@code Capability} is equal to the other * object; {@code false} otherwise. */ boolean equals(Object obj); /** * Returns the hashCode of this {@code Capability}. * * @return The hashCode of this {@code Capability}. */ int hashCode(); {code} And we also implement above interface via *org.apache.felix.utils.resource.CapabilityImpl* but this class does not implement equals() and hashCode(). This will be a problem when we have the same bundles expose the same package org.apache.felix.utils.resource.CapabilitySet#addCapability will add dupplicate capability. E.g. I have a feature class named "my-feature" and this feature contains {code:java} <repository>mvn:org.apache.cxf.karaf/apache-cxf/${cxf.version}/xml/features</repository> <feature name="my-feature"> <bundle>mvn:org.apache.cxf/cxf-core/${cxf.version}</bundle> ... my other bundles ... </feature> {code} During startup time, felix resolve export-packages from cxf-core and found that cxf-core packages are exposed by 2 bundles (first one from cxf-core in repository and the other from my-feature). {code:java} {ResourceImpl@24398} "org.apache.cxf.cxf-core/3.3.4" ->{Subsystem@24381} "root#my-feature" {ResourceImpl@24423} "org.apache.cxf.cxf-core/3.3.4" ->{Subsystem@24414} "root#cxf-core-3.3.4" {code} + export packages from cxf-core in repository. {code:java} {CapabilityImpl@7156} "[org.apache.cxf.cxf-core/3.3.4]osgi.wiring.package; version:Version=3.3.4;bundle-symbolic-name=org.apache.cxf.cxf-core;bundle-version:Version=3.3.4;osgi.wiring.package=org.apache.cxf.annotations" ->{RequirementImpl@8400} "[org.apache.cxf.cxf-core/3.3.4] osgi.wiring.package;filter:="(osgi.wiring.package=org.apache.cxf.annotations)"" {CapabilityImpl@7157} "[org.apache.cxf.cxf-core/3.3.4]osgi.wiring.package; version:Version=3.3.4;bundle-symbolic-name=org.apache.cxf.cxf-core;bundle-version:Version=3.3.4; osgi.wiring.package=org.apache.cxf.attachment" ->{RequirementImpl@8401} "[org.apache.cxf.cxf-core/3.3.4] osgi.wiring.package;filter:="(osgi.wiring.package=org.apache.cxf.attachment)"" {code} + export packages from cxf-core in my-feature. {code:java} {CapabilityImpl@9196} "[org.apache.cxf.cxf-core/3.3.4] osgi.wiring.package; version:Version=3.3.4; bundle-symbolic-name=org.apache.cxf.cxf-core;bundle-version:Version=3.3.4;osgi.wiring.package=org.apache.cxf.annotations" ->{RequirementImpl@8142} "[org.apache.cxf.cxf-core/3.3.4] osgi.wiring.package;filter:="(osgi.wiring.package=org.apache.cxf.annotations)"" {CapabilityImpl@9197} "[org.apache.cxf.cxf-core/3.3.4]osgi.wiring.package; version:Version=3.3.4;bundle-symbolic-name=org.apache.cxf.cxf-core;bundle-version:Version=3.3.4; osgi.wiring.package=org.apache.cxf.attachment" ->{RequirementImpl@8146} "[org.apache.cxf.cxf-core/3.3.4] osgi.wiring.package;filter:="(osgi.wiring.package=org.apache.cxf.attachment)"" {code} Due to this, these export-package from cxf-core will be moved to m_substPermutations in *org.apache.felix.resolver.ResolverImpl* via *org.apache.felix.resolver.ResolverImpl.ResolveSession#addPermutation*. If m_substPermutations grow huge, this will be a performence issue as each permutation keep ~ 1mb. Is there any reason why are we not implement *equals()* and *hashCode()* in Capability? I think if we implement these methods, the size of *CapabilitySet* can be reduced because we don't add duplicate Capability. Thanks, Tuan. was: Hi Felix devs, I'm using karaf 4.2.7 which include felix util 1.11.2 There is an interface *org.osgi.resource.Capability* with these methods {code:java} /** * Compares this {@code Capability} to another {@code Capability}. * * <p> * This {@code Capability} is equal to another {@code Capability} if they * have the same namespace, directives and attributes and are declared by * the same resource. * * @param obj The object to compare against this {@code Capability}. * @return {@code true} if this {@code Capability} is equal to the other * object; {@code false} otherwise. */ boolean equals(Object obj); /** * Returns the hashCode of this {@code Capability}. * * @return The hashCode of this {@code Capability}. */ int hashCode(); {code} And we also implement above interface via *org.apache.felix.utils.resource.CapabilityImpl* but this class does not implement equals() and hashCode(). This will be a problem when we have the same bundles expose the same package org.apache.felix.utils.resource.CapabilitySet#addCapability will add dupplicate capability. E.g. I have a feature class named "my-feature" and this feature contains <repository>mvn:org.apache.cxf.karaf/apache-cxf/${cxf.version}/xml/features</repository> <feature name="my-feature"> <bundle>mvn:org.apache.cxf/cxf-core/${cxf.version}</bundle> ... my other bundles ... </feature> During startup time, felix resolve export-packages from cxf-core and found that cxf-core packages are exposed by 2 bundles (first one from cxf-core in repository and the other from my-feature). {ResourceImpl@24398} "org.apache.cxf.cxf-core/3.3.4" ->\{Subsystem@24381} "root#my-feature" {ResourceImpl@24423} "org.apache.cxf.cxf-core/3.3.4" ->\{Subsystem@24414} "root#cxf-core-3.3.4" + export packages from cxf-core in repository. {CapabilityImpl@7156} "[org.apache.cxf.cxf-core/3.3.4]osgi.wiring.package; version:Version=3.3.4;bundle-symbolic-name=org.apache.cxf.cxf-core;bundle-version:Version=3.3.4;osgi.wiring.package=org.apache.cxf.annotations" ->\{RequirementImpl@8400} "[org.apache.cxf.cxf-core/3.3.4] osgi.wiring.package;filter:="(osgi.wiring.package=*org.apache.cxf.annotations*)"" {CapabilityImpl@7157} "[org.apache.cxf.cxf-core/3.3.4]osgi.wiring.package; version:Version=3.3.4;bundle-symbolic-name=org.apache.cxf.cxf-core;bundle-version:Version=3.3.4; osgi.wiring.package=org.apache.cxf.attachment" ->\{RequirementImpl@8401} "[org.apache.cxf.cxf-core/3.3.4] osgi.wiring.package;filter:="(osgi.wiring.package=*org.apache.cxf.attachment*)"" + export packages from cxf-core in my-feature. {CapabilityImpl@9196} "[org.apache.cxf.cxf-core/3.3.4] osgi.wiring.package; version:Version=3.3.4; bundle-symbolic-name=org.apache.cxf.cxf-core;bundle-version:Version=3.3.4;osgi.wiring.package=org.apache.cxf.annotations" ->\{RequirementImpl@8142} "[org.apache.cxf.cxf-core/3.3.4] osgi.wiring.package;filter:="(osgi.wiring.package=*org.apache.cxf.annotations)*"" {CapabilityImpl@9197} "[org.apache.cxf.cxf-core/3.3.4]osgi.wiring.package; version:Version=3.3.4;bundle-symbolic-name=org.apache.cxf.cxf-core;bundle-version:Version=3.3.4; osgi.wiring.package=org.apache.cxf.attachment" ->\{RequirementImpl@8146} "[org.apache.cxf.cxf-core/3.3.4] osgi.wiring.package;filter:="(osgi.wiring.package=*org.apache.cxf.attachment*)"" Due to this, these export-package from cxf-core will be moved to m_substPermutations in *org.apache.felix.resolver.ResolverImpl* via *org.apache.felix.resolver.ResolverImpl.ResolveSession#addPermutation*. If m_substPermutations grow huge, this will be a performence issue as each permutation keep ~ 1mb. Is there any reason why are we not implement *equals()* and *hashCode()* in Capability? I think if we implement these methods, the size of *CapabilitySet* can be reduced because we don't add duplicate Capability. Thanks, Tuan. > Implement equals() and hashCode() for > org.apache.felix.utils.resource.CapabilityImpl in Felix util > --------------------------------------------------------------------------------------------------- > > Key: FELIX-6258 > URL: https://issues.apache.org/jira/browse/FELIX-6258 > Project: Felix > Issue Type: Bug > Components: Felix Commons > Affects Versions: utils-1.11.4 > Reporter: Tuan > Priority: Major > > Hi Felix devs, > I'm using karaf 4.2.7 which include felix util 1.11.2 > There is an interface *org.osgi.resource.Capability* with these methods > {code:java} > /** > * Compares this {@code Capability} to another {@code > Capability}. > * > * <p> > * This {@code Capability} is equal to another {@code > Capability} if they > * have the same namespace, directives and attributes > and are declared by > * the same resource. > * > * @param obj The object to compare against this {@code > Capability}. > * @return {@code true} if this {@code Capability} is > equal to the other > * object; {@code false} otherwise. > */ > boolean equals(Object obj); > /** > * Returns the hashCode of this {@code Capability}. > * > * @return The hashCode of this {@code Capability}. > */ > int hashCode(); > {code} > And we also implement above interface via > *org.apache.felix.utils.resource.CapabilityImpl* but this class does not > implement equals() and hashCode(). > This will be a problem when we have the same bundles expose the same > package org.apache.felix.utils.resource.CapabilitySet#addCapability > will add dupplicate capability. > E.g. I have a feature class named "my-feature" and this feature contains > {code:java} > <repository>mvn:org.apache.cxf.karaf/apache-cxf/${cxf.version}/xml/features</repository> > <feature name="my-feature"> > <bundle>mvn:org.apache.cxf/cxf-core/${cxf.version}</bundle> > ... my other bundles ... > </feature> > {code} > During startup time, felix resolve export-packages from cxf-core and found > that cxf-core packages are exposed by 2 bundles (first one from > cxf-core in repository and the other from my-feature). > > {code:java} > {ResourceImpl@24398} "org.apache.cxf.cxf-core/3.3.4" ->{Subsystem@24381} > "root#my-feature" > {ResourceImpl@24423} "org.apache.cxf.cxf-core/3.3.4" ->{Subsystem@24414} > "root#cxf-core-3.3.4" > {code} > > + export packages from cxf-core in repository. > > {code:java} > {CapabilityImpl@7156} > "[org.apache.cxf.cxf-core/3.3.4]osgi.wiring.package; > version:Version=3.3.4;bundle-symbolic-name=org.apache.cxf.cxf-core;bundle-version:Version=3.3.4;osgi.wiring.package=org.apache.cxf.annotations" > ->{RequirementImpl@8400} "[org.apache.cxf.cxf-core/3.3.4] > > osgi.wiring.package;filter:="(osgi.wiring.package=org.apache.cxf.annotations)"" > {CapabilityImpl@7157} > "[org.apache.cxf.cxf-core/3.3.4]osgi.wiring.package; > version:Version=3.3.4;bundle-symbolic-name=org.apache.cxf.cxf-core;bundle-version:Version=3.3.4; > osgi.wiring.package=org.apache.cxf.attachment" ->{RequirementImpl@8401} > "[org.apache.cxf.cxf-core/3.3.4] > > osgi.wiring.package;filter:="(osgi.wiring.package=org.apache.cxf.attachment)"" > {code} > > + export packages from cxf-core in my-feature. > > {code:java} > {CapabilityImpl@9196} > "[org.apache.cxf.cxf-core/3.3.4] osgi.wiring.package; version:Version=3.3.4; > bundle-symbolic-name=org.apache.cxf.cxf-core;bundle-version:Version=3.3.4;osgi.wiring.package=org.apache.cxf.annotations" > ->{RequirementImpl@8142} "[org.apache.cxf.cxf-core/3.3.4] > > osgi.wiring.package;filter:="(osgi.wiring.package=org.apache.cxf.annotations)"" > {CapabilityImpl@9197} > "[org.apache.cxf.cxf-core/3.3.4]osgi.wiring.package; > version:Version=3.3.4;bundle-symbolic-name=org.apache.cxf.cxf-core;bundle-version:Version=3.3.4; > osgi.wiring.package=org.apache.cxf.attachment" ->{RequirementImpl@8146} > "[org.apache.cxf.cxf-core/3.3.4] > > osgi.wiring.package;filter:="(osgi.wiring.package=org.apache.cxf.attachment)"" > {code} > > > Due to this, these export-package from cxf-core will be moved to > m_substPermutations in *org.apache.felix.resolver.ResolverImpl* via > *org.apache.felix.resolver.ResolverImpl.ResolveSession#addPermutation*. > If m_substPermutations grow huge, this will be a performence issue as each > permutation keep ~ 1mb. > Is there any reason why are we not implement *equals()* and *hashCode()* in > Capability? > I think if we implement these methods, the size of *CapabilitySet* can be > reduced because we don't add duplicate Capability. > Thanks, > Tuan. -- This message was sent by Atlassian Jira (v8.3.4#803005)