Skip to content

Commit

Permalink
Remove redundant setPrimary(true) and wrong setLazyInit(true)
Browse files Browse the repository at this point in the history
Both of `@Primary` and `@Lazy` are already processed by `AnnotationConfigUtils.processCommonDefinitionAnnotations(abd)`, and `setLazyInit()` should use value of `@Lazy` not fixed `true`.
  • Loading branch information
quaff committed Sep 13, 2024
1 parent f6c6f7c commit e29cbd2
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* @author Chris Beams
* @author Sam Brannen
* @author Phillip Webb
* @author Yanming Zhou
* @since 3.0
* @see AnnotationConfigApplicationContext#register
*/
Expand Down Expand Up @@ -263,13 +264,8 @@ private <T> void doRegisterBean(Class<T> beanClass, @Nullable String name,
AnnotationConfigUtils.processCommonDefinitionAnnotations(abd);
if (qualifiers != null) {
for (Class<? extends Annotation> qualifier : qualifiers) {
if (Primary.class == qualifier) {
abd.setPrimary(true);
}
else if (Lazy.class == qualifier) {
abd.setLazyInit(true);
}
else {
if (Primary.class != qualifier && Lazy.class != qualifier) {
// Primary and Lazy is processed by AnnotationConfigUtils.processCommonDefinitionAnnotations()
abd.addQualifier(new AutowireCandidateQualifier(qualifier));
}
}
Expand Down

0 comments on commit e29cbd2

Please sign in to comment.