Presort beans in ControllerAdviceBean.findAnnotatedBeans() #23188
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Status Quo
The
findAnnotatedBeans(ApplicationContext)
static utility method inControllerAdviceBean
currently does not sort the list it returns. However, every use case within the Spring Framework currently sorts the returned list immediately -- for example, inControllerMethodResolver.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 aControllerAdviceBean
is never annotated with@Order
or@Priority
:@Order
or@Priority
are already honored internally inControllerAdviceBean#getOrder()
. We should therefore only sortControllerAdviceBean
instances usingOrderComparator
.Deliverables
ControllerAdviceBean
instances usingOrderComparator
directly withinControllerAdviceBean.findAnnotatedBeans()
.The text was updated successfully, but these errors were encountered: