applied synchronization in order to avoid race condition in skipping check (SPR-7635, SPR-7642)
This commit is contained in:
parent
21d6883139
commit
7893b3ebf6
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue