Browse Source

Tighten cacheable decision behind @Lazy injection point

Closes gh-35917
pull/35933/head
Juergen Hoeller 3 weeks ago
parent
commit
61d5413c23
  1. 29
      spring-context/src/main/java/org/springframework/context/annotation/ContextAnnotationAutowireCandidateResolver.java

29
spring-context/src/main/java/org/springframework/context/annotation/ContextAnnotationAutowireCandidateResolver.java

@ -168,22 +168,25 @@ public class ContextAnnotationAutowireCandidateResolver extends QualifierAnnotat
} }
} }
boolean cacheable = true; boolean cacheable = false;
for (String autowiredBeanName : autowiredBeanNames) { if (!autowiredBeanNames.isEmpty()) {
if (!this.beanFactory.containsBean(autowiredBeanName)) { cacheable = true;
cacheable = false; for (String autowiredBeanName : autowiredBeanNames) {
} if (!this.beanFactory.containsBean(autowiredBeanName)) {
else {
if (this.beanName != null) {
this.beanFactory.registerDependentBean(autowiredBeanName, this.beanName);
}
if (!this.beanFactory.isSingleton(autowiredBeanName)) {
cacheable = false; cacheable = false;
} }
else {
if (this.beanName != null) {
this.beanFactory.registerDependentBean(autowiredBeanName, this.beanName);
}
if (!this.beanFactory.isSingleton(autowiredBeanName)) {
cacheable = false;
}
}
} }
if (cacheable) { }
this.cachedTarget = target; if (cacheable) {
} this.cachedTarget = target;
} }
return target; return target;

Loading…
Cancel
Save