Overview
While implementing a fix for the regression raised in #23985, it became apparent that methods in a @ControllerAdvice bean end up being registered and invoked twice if the advice is a scoped bean (e.g., request or session scoped). In other words, both the proxy bean and the target bean are wrapped in ControllerAdviceBean instances.
The reason this happens is that ControllerAdviceBean.findAnnotatedBeans() finds all beans in the ApplicationContext that are annotated with @ControllerAdvice.
Deliverables
Overview
While implementing a fix for the regression raised in #23985, it became apparent that methods in a
@ControllerAdvicebean end up being registered and invoked twice if the advice is a scoped bean (e.g., request or session scoped). In other words, both the proxy bean and the target bean are wrapped inControllerAdviceBeaninstances.The reason this happens is that
ControllerAdviceBean.findAnnotatedBeans()finds all beans in theApplicationContextthat are annotated with@ControllerAdvice.Deliverables
ControllerAdviceBean.findAnnotatedBeans()does not contain target beans for scoped proxies.