Skip to content

@Configuration(proxyBeanMethods = false) cannot implement ImportAware #22920

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

Closed
eleftherias opened this issue May 7, 2019 · 2 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@eleftherias
Copy link

When a configuration class is annotated with @Configuration(proxyBeanMethods = false) and also implements ImportAware, the method setImportMetadata never gets called.

I have created a sample that demonstates this behaviour through a failing test
https://github.com/eleftherias/spring-import-aware-no-proxy/blob/master/src/test/java/com/example/importawarenoproxy/ImportAwareNoProxyApplicationTests.java

It seems to be cause by this line

AnnotationMetadata importingClass = ir.getImportingClassFor(bean.getClass().getSuperclass().getName());

When a configuration class e.g BasicConfig is annotated with @Configuration the bean class is BasicConfig$$EnhancerBySpringCGLIB and the superclass name is BasicConfig.
However, when the class is annotated with @Configuration(proxyBeanMethods = false) the bean class is BasicConfig and the superclass is Object, which causes the importingClass to be null.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 7, 2019
@jhoeller jhoeller self-assigned this May 7, 2019
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels May 7, 2019
@jhoeller jhoeller added this to the 5.2 M2 milestone May 7, 2019
@jhoeller
Copy link
Contributor

jhoeller commented May 7, 2019

Well spotted, @eleftherias, and very timely!

@eleftherias
Copy link
Author

Thanks for the fix, this solved our issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants