ControllerAdviceBean.findAnnotatedBeans() finds proxies as well as their target beans, resulting in double registration #24017
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
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 inControllerAdviceBean
instances.The reason this happens is that
ControllerAdviceBean.findAnnotatedBeans()
finds all beans in theApplicationContext
that are annotated with@ControllerAdvice
.Deliverables
ControllerAdviceBean.findAnnotatedBeans()
does not contain target beans for scoped proxies.The text was updated successfully, but these errors were encountered: