Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Presort beans in ControllerAdviceBean.findAnnotatedBeans() #23188

Closed
1 task done
sbrannen opened this issue Jun 24, 2019 · 0 comments
Closed
1 task done

Presort beans in ControllerAdviceBean.findAnnotatedBeans() #23188

sbrannen opened this issue Jun 24, 2019 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Jun 24, 2019

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 ControllerAdviceBean instances using OrderComparator directly within ControllerAdviceBean.findAnnotatedBeans().
@sbrannen sbrannen added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement labels Jun 24, 2019
@sbrannen sbrannen added this to the 5.2 RC1 milestone Jun 24, 2019
@sbrannen sbrannen self-assigned this Jun 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant