Thomas Watson created ARIES-1554:
------------------------------------

             Summary: FelixResourceAdapter returns true for resources of other 
types
                 Key: ARIES-1554
                 URL: https://issues.apache.org/jira/browse/ARIES-1554
             Project: Aries
          Issue Type: Bug
          Components: Subsystem
         Environment: All
            Reporter: Thomas Watson
            Assignee: Thomas Watson


The Resource implementation 
org.apache.aries.subsystem.util.felix.FelixResourceAdapter does an equality 
check based on the osgi.identity name, version, and type.  This typically is 
not an issue but the contract for Resource.equals states the following:

<javadoc>
This Resource is equal to another Resource if both have the same content and 
come from the same location. Location may be defined as the bundle location if 
the resource is an installed bundle or the repository location if the resource 
is in a repository.
</javadoc>

The assumption is that if the osgi.identity name, version and type are equal 
then the resources have the "same content".  But the implementation does not 
take into account the location.  This causes issues if resources are used as 
keys in a Map and the Map will contain resources of different implementation 
types.  This is done by the felix resolver implementation.  In some scenarios 
the subsystems will return to the resolver resources from the OBR repository 
and from the system repository (installed bundles) that have the same name, 
version, type.  From the resolver's perspective these two resources must be 
treated as distinctly different resources because they come from completely 
different locations.  And the framework's Resource implementation of equals 
does return false if checked against a FelixResourceAdapter, but the 
FelixResourceAdapter equals method will return true if check against the 
framework's Resource implementation.  This inconsistency in the equals behavior 
reeks havoc for Map implementations.  Usually the issue is very intermittent 
because of they way hash slots are determined based on hashcodes, but in rare 
cases these two resources will be slotted the same and collide with eachother 
depending on the Map implementation.

At a minimum the FelixResourceAdapter should check that the other object is an 
instance of FelixResourceAdapter to be able to return true.  This makes the 
simple assumption that if the Resource is not of type FelixResourceAdapter then 
there is no way the resource is at the same location.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to