diff --git a/core-common/src/main/java/org/glassfish/jersey/internal/inject/Providers.java b/core-common/src/main/java/org/glassfish/jersey/internal/inject/Providers.java index 8380bc5202..e66a70ad36 100644 --- a/core-common/src/main/java/org/glassfish/jersey/internal/inject/Providers.java +++ b/core-common/src/main/java/org/glassfish/jersey/internal/inject/Providers.java @@ -315,7 +315,7 @@ public static Collection> getAllServiceHolders(InjectionMan contract, Comparator.comparingInt(Providers::getPriority), CustomAnnotationLiteral.INSTANCE); - providers.addAll(getServiceHolders(injectionManager, contract)); + providers.addAll(getServiceHolders(injectionManager, contract, Comparator.comparingInt(Providers::getPriority))); LinkedHashSet> providersSet = new LinkedHashSet<>(); for (ServiceHolder provider : providers) { @@ -337,8 +337,8 @@ private static List> getServiceHolders(InjectionManager inj Comparator> objectComparator, Annotation... qualifiers) { - List> serviceHolders = injectionManager.getAllServiceHolders(contract, qualifiers); - serviceHolders.sort((o1, o2) -> objectComparator.compare(o1.getImplementationClass(), o2.getImplementationClass())); + List> serviceHolders = getServiceHolders(injectionManager, contract, qualifiers); + serviceHolders.sort((o1, o2) -> objectComparator.compare(o1.getInstance().getClass(), o2.getInstance().getClass())); return serviceHolders; }