提交 7893b3eb 编写于 作者: J Juergen Hoeller

applied synchronization in order to avoid race condition in skipping check (SPR-7635, SPR-7642)

上级 21d68831
......@@ -468,7 +468,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
value = resolvedCachedArgument(beanName, this.cachedFieldValue);
}
else {
synchronized (this) {
synchronized (pvs) {
if (!this.cached) {
Set<String> autowiredBeanNames = new LinkedHashSet<String>(1);
TypeConverter typeConverter = beanFactory.getTypeConverter();
......@@ -527,10 +527,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
@Override
protected void inject(Object bean, String beanName, PropertyValues pvs) throws Throwable {
if (this.skip == null) {
this.skip = checkPropertySkipping(pvs);
}
if (this.skip) {
if (checkPropertySkipping(pvs)) {
return;
}
Method method = (Method) this.member;
......@@ -541,7 +538,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
arguments = resolveCachedArguments(beanName);
}
else {
synchronized (this) {
synchronized (pvs) {
if (!this.cached) {
Class[] paramTypes = method.getParameterTypes();
arguments = new Object[paramTypes.length];
......
......@@ -147,10 +147,7 @@ public class InjectionMetadata {
field.set(target, getResourceToInject(target, requestingBeanName));
}
else {
if (this.skip == null) {
this.skip = checkPropertySkipping(pvs);
}
if (this.skip) {
if (checkPropertySkipping(pvs)) {
return;
}
try {
......@@ -170,16 +167,24 @@ public class InjectionMetadata {
* affected property as processed for other processors to ignore it.
*/
protected boolean checkPropertySkipping(PropertyValues pvs) {
if (this.pd != null && pvs != null) {
if (pvs.getPropertyValue(this.pd.getName()) != null) {
// Explicit value provided as part of the bean definition.
return true;
}
else if (pvs instanceof MutablePropertyValues) {
((MutablePropertyValues) pvs).registerProcessedProperty(this.pd.getName());
if (this.skip == null) {
synchronized (pvs) {
if (this.skip == null) {
if (this.pd != null && pvs != null) {
if (pvs.contains(this.pd.getName())) {
// Explicit value provided as part of the bean definition.
this.skip = true;
return true;
}
else if (pvs instanceof MutablePropertyValues) {
((MutablePropertyValues) pvs).registerProcessedProperty(this.pd.getName());
}
}
this.skip = false;
}
}
}
return false;
return this.skip;
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册