Skip to content

ControllerAdviceBean.findAnnotatedBeans() finds proxies as well as their target beans, resulting in double registration #24017

@sbrannen

Description

@sbrannen

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

  • Ensure that the list returned by ControllerAdviceBean.findAnnotatedBeans() does not contain target beans for scoped proxies.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions