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

ScopedProxyMode resolution for custom scope meta-annotation not working with @Bean methods (with ASM-based scanning) [SPR-13394] #17974

spring-projects-issues opened this issue Aug 25, 2015 · 2 comments
in: core status: backported type: bug


Copy link

@spring-projects-issues spring-projects-issues commented Aug 25, 2015

Leonard Loesche opened SPR-13394 and commented

The Meta-Annotation for @RefreshScope (as mentioned in the linked ticket) overwrites the default proxyMode (with ScopedProxyMode.TARGET_CLASS) which is unfortunately only working with an annotation at type level (with proxy mode resolution via ClassPathBeanDefinitionScanner and a ScopeMetadataResolver) but not for @Bean annotated methods, which uses a different approach to resolve the proxyMode.
Even setting the proxyMode manually at the custom scope annotation does not help.

There is the 'workaround', not to use the meta annotation but the original @Scope with correct proxyMode at the method, but it would be an improvement to have the same behaviour for the custom scope annotation on both sides.

Affects: 4.1.6, 4.2 GA

Reference URL: spring-cloud/spring-cloud-config#190


Issue Links:

  • #17870 Support custom base scope annotation type for @Bean methods

Referenced from: commits 75187e3, 3430f76

Backported to: 4.1.8

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 25, 2015

Leonard Loesche commented

Attached a test project with usage of spring-boot 1.3.0.M4 which uses spring framework 4.2.GA.

It further uses spring-cloud-config with the mentioned @RefreshScope annotation and the included "refresh" controller action which cleares the scope map, causing a recreation of the proxied target instance.

There are three tests implemented at the moment - one of them failing, which tests the reported issue. In that scenario the bean instance is not being created a second time, because the referencing bean (here: a controller) keeps the non-proxied first instance.
The other two tests show the working variants with annotation at type level and the mentioned workaround.

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 25, 2015

Juergen Hoeller commented

This seems to be a problem with ASM-based resolution only... which is why we didn't catch it before: our unit tests use direct Class references and therefore reflection-based resolution.

We'll fix this for 4.2.1 and 4.1.8, since scope meta-annotations are supposed to work with @Bean methods in any mode.


@spring-projects-issues spring-projects-issues added type: bug status: backported in: core labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.2.1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: core status: backported type: bug
None yet

No branches or pull requests

2 participants