unitsofmeasurement / unit-api

Units of Measurement API
http://unitsofmeasurement.github.io/unit-api/
Other
180 stars 42 forks source link

Priority not for sorting in ServiceProvider? #195

Closed keilw closed 3 years ago

keilw commented 5 years ago

After changes to ServiceProvider by @desruisseaux the priority seems ignored, at least for sorting in the available() method:

[INFO] Running systems.uom.common.SystemOfUnitsServiceTest
Default
SI
Common

However, DefaultServiceProvider has a priority of 10 (not using the annotation, only the integer method), SIServiceProvider has 100 and CommonServiceProvider has 1000, so they are in completely the wrong order or rather seem not sorted at all. Previously the ServiceProvider with the highest priority would become current(). Which was changed based on the implementation notes of the current member, but if the priority is not used any more not even to sort the available() service providers list, why do we still need it?

keilw commented 3 years ago

Actually it works, but it was previously sorted ascending, so lower numbers like 1 or 10 first. While the priority number could be defined based on any particular need, some usage of the Priority annotations like Priorities in Jakarta REST/JAX-RS also use the highest number as the default.