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

AnnotatedBeanDefinitionReader should respect @Fallback qualifier analogous to @Primary #33533

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

quaff
Copy link
Contributor

@quaff quaff commented Sep 13, 2024

Also add tests to cover qualifier classes.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 13, 2024
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Sep 13, 2024
@liuao1004
Copy link

Hi, I think the code is not redundant. You will be right if someone use the method registerBean in AnnotatedBeanDefinitionReader without providing qualifiers.
In fact, the fixed true is just the defalut value for @Lazy or @Primray.

StaticApplicationContext context = new StaticApplicationContext();
AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(context);
reader.registerBean(User.class, "user", Lazy.class);
BeanDefinition definition = context.getBeanDefinition("user");
// must be true
assert definition.isLazyInit();

@quaff
Copy link
Contributor Author

quaff commented Sep 13, 2024

Hi, I think the code is not redundant. You will be right if someone use the method registerBean in AnnotatedBeanDefinitionReader without providing qualifiers. In fact, the fixed true is just the defalut value for @Lazy or @Primray.

StaticApplicationContext context = new StaticApplicationContext();
AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(context);
reader.registerBean(User.class, "user", Lazy.class);
BeanDefinition definition = context.getBeanDefinition("user");
// must be true
assert definition.isLazyInit();

Thanks for point out, It seems not covered by tests, I will add tests instead.

@quaff quaff marked this pull request as draft September 13, 2024 12:05
@quaff quaff changed the title Remove redundant setPrimary(true) and wrong setLazyInit(true) AnnotatedBeanDefinitionReader should respect Fallback.class qualifier as same as Primary.class Sep 13, 2024
@quaff quaff marked this pull request as ready for review September 13, 2024 12:38
@quaff quaff force-pushed the patch-84 branch 3 times, most recently from 2186810 to 58db79e Compare September 13, 2024 13:31
@jhoeller jhoeller added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 16, 2024
@jhoeller jhoeller self-assigned this Sep 16, 2024
@jhoeller jhoeller modified the milestone: 6.2.0-RC2 Sep 16, 2024
@jhoeller
Copy link
Contributor

@quaff this looks good to me. Just one glitch: AnnotatedBeanDefinitionReaderTests seems to be defined in a file named AnnotationBeanDefinitionReaderTests, or am I misreading this?

@sbrannen sbrannen changed the title AnnotatedBeanDefinitionReader should respect Fallback.class qualifier as same as Primary.class AnnotatedBeanDefinitionReader should respect @Fallback qualifier analogous to @Primary Sep 17, 2024
@quaff
Copy link
Contributor Author

quaff commented Sep 18, 2024

@quaff this looks good to me. Just one glitch: AnnotatedBeanDefinitionReaderTests seems to be defined in a file named AnnotationBeanDefinitionReaderTests, or am I misreading this?

My mistake, fixed now.

…ogous to @primary

Also add tests to cover qualifier classes.
@jhoeller jhoeller merged commit 24a8f1b into spring-projects:main Sep 20, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

5 participants