Feature in higher version takes precedence even if it has lower type order

Closes #34635

Signed-off-by: vramik <vramik@redhat.com>
This commit is contained in:
vramik 2024-11-04 17:14:59 +01:00 committed by Alexander Schwartz
parent b1ff9511d1
commit a2ba3c8ace

View file

@ -339,13 +339,13 @@ public class Profile {
*/
private static Map<String, TreeSet<Feature>> getOrderedFeatures() {
if (FEATURES == null) {
// "natural" ordering low to high between two features
Comparator<Feature> comparator = Comparator.comparing(Feature::getType).thenComparingInt(Feature::getVersion);
// "natural" ordering low to high between two features (type has precedence and then reversed version is used)
Comparator<Feature> comparator = Comparator.comparing(Feature::getType).thenComparing(Comparator.comparingInt(Feature::getVersion).reversed());
// aggregate the features by unversioned key
HashMap<String, TreeSet<Feature>> features = new HashMap<>();
Stream.of(Feature.values()).forEach(f -> features.compute(f.getUnversionedKey(), (k, v) -> {
if (v == null) {
v = new TreeSet<>(comparator.reversed()); // we want the highest priority first
v = new TreeSet<>(comparator);
}
v.add(f);
return v;