-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Description
Status Quo
The findAnnotatedBeans(ApplicationContext) static utility method in ControllerAdviceBean currently does not sort the list it returns. However, every use case within the Spring Framework currently sorts the returned list immediately -- for example, in ControllerMethodResolver.initControllerAdviceCaches(ApplicationContext) (WebFlux), ExceptionHandlerExceptionResolver.initExceptionHandlerAdviceCache() (Web MVC), etc.
Since every known use case needs the beans sorted, we should just sort them upfront.
In addition, the current clients of this utility method sort the beans using AnnotationAwareOrderComparator which adds unnecessary overhead since a ControllerAdviceBean is never annotated with @Order or @Priority: @Order or @Priority are already honored internally in ControllerAdviceBean#getOrder(). We should therefore only sort ControllerAdviceBean instances using OrderComparator.
Deliverables
- Sort
ControllerAdviceBeaninstances usingOrderComparatordirectly withinControllerAdviceBean.findAnnotatedBeans().