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