Skip to content

Commit 7317457

Browse files
committed
Consistent bridge method handling in annotation post-processors
Issue: SPR-12495
1 parent ad71c6a commit 7317457

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

spring-beans/src/main/java/org/springframework/beans/BeanUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ public static PropertyDescriptor findPropertyForMethod(Method method) throws Bea
395395
* @param clazz the (most specific) class to introspect for descriptors
396396
* @return the corresponding PropertyDescriptor, or {@code null} if none
397397
* @throws BeansException if PropertyDescriptor lookup fails
398-
* @since 4.0.9
398+
* @since 3.2.13
399399
*/
400400
public static PropertyDescriptor findPropertyForMethod(Method method, Class<?> clazz) throws BeansException {
401401
Assert.notNull(method, "Method must not be null");
@@ -609,7 +609,7 @@ private static void copyProperties(Object source, Object target, Class<?> editab
609609

610610
for (PropertyDescriptor targetPd : targetPds) {
611611
Method writeMethod = targetPd.getWriteMethod();
612-
if (writeMethod != null && (ignoreList == null || (!ignoreList.contains(targetPd.getName())))) {
612+
if (writeMethod != null && (ignoreList == null || !ignoreList.contains(targetPd.getName()))) {
613613
PropertyDescriptor sourcePd = getPropertyDescriptor(source.getClass(), targetPd.getName());
614614
if (sourcePd != null) {
615615
Method readMethod = sourcePd.getReadMethod();

spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ public void doWith(Method method) throws IllegalArgumentException, IllegalAccess
269269
Constructor<?> requiredConstructor = null;
270270
Constructor<?> defaultConstructor = null;
271271
for (Constructor<?> candidate : rawCandidates) {
272-
AnnotationAttributes annotation = findAutowiredAnnotation(candidate);
273-
if (annotation != null) {
272+
AnnotationAttributes ann = findAutowiredAnnotation(candidate);
273+
if (ann != null) {
274274
if (requiredConstructor != null) {
275275
throw new BeanCreationException(beanName,
276276
"Invalid autowire-marked constructor: " + candidate +
@@ -281,7 +281,7 @@ public void doWith(Method method) throws IllegalArgumentException, IllegalAccess
281281
throw new IllegalStateException(
282282
"Autowired annotation requires at least one argument: " + candidate);
283283
}
284-
boolean required = determineRequiredStatus(annotation);
284+
boolean required = determineRequiredStatus(ann);
285285
if (required) {
286286
if (!candidates.isEmpty()) {
287287
throw new BeanCreationException(beanName,
@@ -384,15 +384,15 @@ private InjectionMetadata buildAutowiringMetadata(Class<?> clazz) {
384384
do {
385385
LinkedList<InjectionMetadata.InjectedElement> currElements = new LinkedList<InjectionMetadata.InjectedElement>();
386386
for (Field field : targetClass.getDeclaredFields()) {
387-
AnnotationAttributes annotation = findAutowiredAnnotation(field);
388-
if (annotation != null) {
387+
AnnotationAttributes ann = findAutowiredAnnotation(field);
388+
if (ann != null) {
389389
if (Modifier.isStatic(field.getModifiers())) {
390390
if (logger.isWarnEnabled()) {
391391
logger.warn("Autowired annotation is not supported on static fields: " + field);
392392
}
393393
continue;
394394
}
395-
boolean required = determineRequiredStatus(annotation);
395+
boolean required = determineRequiredStatus(ann);
396396
currElements.add(new AutowiredFieldElement(field, required));
397397
}
398398
}
@@ -429,9 +429,9 @@ private InjectionMetadata buildAutowiringMetadata(Class<?> clazz) {
429429

430430
private AnnotationAttributes findAutowiredAnnotation(AccessibleObject ao) {
431431
for (Class<? extends Annotation> type : this.autowiredAnnotationTypes) {
432-
AnnotationAttributes annotation = AnnotatedElementUtils.getAnnotationAttributes(ao, type.getName());
433-
if (annotation != null) {
434-
return annotation;
432+
AnnotationAttributes ann = AnnotatedElementUtils.getAnnotationAttributes(ao, type.getName());
433+
if (ann != null) {
434+
return ann;
435435
}
436436
}
437437
return null;
@@ -442,12 +442,12 @@ private AnnotationAttributes findAutowiredAnnotation(AccessibleObject ao) {
442442
* <p>A 'required' dependency means that autowiring should fail when no beans
443443
* are found. Otherwise, the autowiring process will simply bypass the field
444444
* or method when no beans are found.
445-
* @param annotation the Autowired annotation
445+
* @param ann the Autowired annotation
446446
* @return whether the annotation indicates that a dependency is required
447447
*/
448-
protected boolean determineRequiredStatus(AnnotationAttributes annotation) {
449-
return (!annotation.containsKey(this.requiredParameterName) ||
450-
this.requiredParameterValue == annotation.getBoolean(this.requiredParameterName));
448+
protected boolean determineRequiredStatus(AnnotationAttributes ann) {
449+
return (!ann.containsKey(this.requiredParameterName) ||
450+
this.requiredParameterValue == ann.getBoolean(this.requiredParameterName));
451451
}
452452

453453
/**

0 commit comments

Comments
 (0)