fixed @Value injection to correctly cache temporary null results for non-singleton beans (SPR-7614)

This commit is contained in:
Juergen Hoeller
2010-10-14 19:40:36 +00:00
parent 5cb06f5da2
commit 1933b648c3
2 changed files with 44 additions and 12 deletions

View File

@@ -474,7 +474,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
value = beanFactory.resolveDependency(descriptor, beanName, autowiredBeanNames, typeConverter);
synchronized (this) {
if (!this.cached) {
if (value != null) {
if (value != null || this.required) {
this.cachedFieldValue = descriptor;
registerDependentBeans(beanName, autowiredBeanNames);
if (autowiredBeanNames.size() == 1) {
@@ -545,7 +545,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
descriptors[i] = new DependencyDescriptor(methodParam, this.required);
arguments[i] = beanFactory.resolveDependency(
descriptors[i], beanName, autowiredBeanNames, typeConverter);
if (arguments[i] == null) {
if (arguments[i] == null && !this.required) {
arguments = null;
break;
}