diff --git a/common/src/main/java/org/keycloak/common/Profile.java b/common/src/main/java/org/keycloak/common/Profile.java index a8e11e69c9..e333387c90 100755 --- a/common/src/main/java/org/keycloak/common/Profile.java +++ b/common/src/main/java/org/keycloak/common/Profile.java @@ -339,13 +339,13 @@ public class Profile { */ private static Map> getOrderedFeatures() { if (FEATURES == null) { - // "natural" ordering low to high between two features - Comparator 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 comparator = Comparator.comparing(Feature::getType).thenComparing(Comparator.comparingInt(Feature::getVersion).reversed()); // aggregate the features by unversioned key HashMap> 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;