Browse Source

fixed Autowired/CommonAnnotationBeanPostProcessor to prevent race condition in skipping check (SPR-7635, SPR-7642)

pull/1234/head
Juergen Hoeller 14 years ago
parent
commit
ac5b1bcfab
  1. 16
      org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
  2. 4
      org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java

16
org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -38,7 +38,6 @@ import org.apache.commons.logging.LogFactory; @@ -38,7 +38,6 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.TypeConverter;
import org.springframework.beans.factory.BeanCreationException;
@ -528,11 +527,10 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean @@ -528,11 +527,10 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
@Override
protected void inject(Object bean, String beanName, PropertyValues pvs) throws Throwable {
if (this.skip == null && this.pd != null && pvs != null && pvs.contains(this.pd.getName())) {
// Explicit value provided as part of the bean definition.
this.skip = Boolean.TRUE;
if (this.skip == null) {
this.skip = checkPropertySkipping(pvs);
}
if (this.skip != null && this.skip) {
if (this.skip) {
return;
}
Method method = (Method) this.member;
@ -590,12 +588,6 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean @@ -590,12 +588,6 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
}
}
}
if (this.skip == null) {
if (this.pd != null && pvs instanceof MutablePropertyValues) {
((MutablePropertyValues) pvs).registerProcessedProperty(this.pd.getName());
}
this.skip = Boolean.FALSE;
}
if (arguments != null) {
ReflectionUtils.makeAccessible(method);
method.invoke(bean, arguments);

4
org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -171,7 +171,7 @@ public class InjectionMetadata { @@ -171,7 +171,7 @@ public class InjectionMetadata {
*/
protected boolean checkPropertySkipping(PropertyValues pvs) {
if (this.pd != null && pvs != null) {
if (pvs.contains(this.pd.getName())) {
if (pvs.getPropertyValue(this.pd.getName()) != null) {
// Explicit value provided as part of the bean definition.
return true;
}

Loading…
Cancel
Save