You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Felix Meschberger (Updated) (JIRA)" <ji...@apache.org> on 2011/10/20 14:15:11 UTC

[jira] [Updated] (FELIX-3175) RankingComparator results in wrong results

     [ https://issues.apache.org/jira/browse/FELIX-3175?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger updated FELIX-3175:
-------------------------------------

    Description: 
The RankingComparator class is used for two cases: ordering ConfigurationPlugin services as per the service.cmRanking property and ordering services as per the service.ranking property. These orderings are slightly different for which the class does not provide properly:

* service.cmRanking sorts ascending and does not define an order amongst services with the same cmRanking value
* service.ranking sorts in descending property value order and defines to fall back to service.id ordering (ascending) in case of equal service.ranking values.

The RankingComparator should be fixed (and simplified) to cope with these two mechanisms.

This should also be tested using unit tests.

  was:
The RankingComparator class works perfectly ordering ServiceReference instances according to the specification. When applied to array sorting (Arrays.sort) and sorted sets (TreeSet), the resulting order is from lowest to highest ServiceReference thus not returning the highest ranking service first.

This is wrong: the highest ranking service should be sorted on the first position and the lowest ranking service should be placed on the last position.

To fix this, the RankingComparator should return revers results:
   -1 if service1 is higher than service2
   0 if service1 is the same as service2 (according to service id)
  +1 if service1 is lower than service2

This should also be tested using unit tests.

    
> RankingComparator results in wrong results
> ------------------------------------------
>
>                 Key: FELIX-3175
>                 URL: https://issues.apache.org/jira/browse/FELIX-3175
>             Project: Felix
>          Issue Type: Bug
>          Components: Configuration Admin
>    Affects Versions: configadmin-1.2.10
>            Reporter: Felix Meschberger
>            Assignee: Felix Meschberger
>             Fix For: configadmin-1.2.12
>
>
> The RankingComparator class is used for two cases: ordering ConfigurationPlugin services as per the service.cmRanking property and ordering services as per the service.ranking property. These orderings are slightly different for which the class does not provide properly:
> * service.cmRanking sorts ascending and does not define an order amongst services with the same cmRanking value
> * service.ranking sorts in descending property value order and defines to fall back to service.id ordering (ascending) in case of equal service.ranking values.
> The RankingComparator should be fixed (and simplified) to cope with these two mechanisms.
> This should also be tested using unit tests.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira