Skip to content

Commit

Permalink
Consistent bridge method handling in annotation post-processors
Browse files Browse the repository at this point in the history
Issue: SPR-12495
  • Loading branch information
jhoeller committed Dec 22, 2014
1 parent ad71c6a commit 7317457
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Expand Up @@ -395,7 +395,7 @@ public static PropertyDescriptor findPropertyForMethod(Method method) throws Bea
* @param clazz the (most specific) class to introspect for descriptors
* @return the corresponding PropertyDescriptor, or {@code null} if none
* @throws BeansException if PropertyDescriptor lookup fails
* @since 4.0.9
* @since 3.2.13
*/
public static PropertyDescriptor findPropertyForMethod(Method method, Class<?> clazz) throws BeansException {
Assert.notNull(method, "Method must not be null");
Expand Down Expand Up @@ -609,7 +609,7 @@ private static void copyProperties(Object source, Object target, Class<?> editab

for (PropertyDescriptor targetPd : targetPds) {
Method writeMethod = targetPd.getWriteMethod();
if (writeMethod != null && (ignoreList == null || (!ignoreList.contains(targetPd.getName())))) {
if (writeMethod != null && (ignoreList == null || !ignoreList.contains(targetPd.getName()))) {
PropertyDescriptor sourcePd = getPropertyDescriptor(source.getClass(), targetPd.getName());
if (sourcePd != null) {
Method readMethod = sourcePd.getReadMethod();
Expand Down
Expand Up @@ -269,8 +269,8 @@ public void doWith(Method method) throws IllegalArgumentException, IllegalAccess
Constructor<?> requiredConstructor = null;
Constructor<?> defaultConstructor = null;
for (Constructor<?> candidate : rawCandidates) {
AnnotationAttributes annotation = findAutowiredAnnotation(candidate);
if (annotation != null) {
AnnotationAttributes ann = findAutowiredAnnotation(candidate);
if (ann != null) {
if (requiredConstructor != null) {
throw new BeanCreationException(beanName,
"Invalid autowire-marked constructor: " + candidate +
Expand All @@ -281,7 +281,7 @@ public void doWith(Method method) throws IllegalArgumentException, IllegalAccess
throw new IllegalStateException(
"Autowired annotation requires at least one argument: " + candidate);
}
boolean required = determineRequiredStatus(annotation);
boolean required = determineRequiredStatus(ann);
if (required) {
if (!candidates.isEmpty()) {
throw new BeanCreationException(beanName,
Expand Down Expand Up @@ -384,15 +384,15 @@ private InjectionMetadata buildAutowiringMetadata(Class<?> clazz) {
do {
LinkedList<InjectionMetadata.InjectedElement> currElements = new LinkedList<InjectionMetadata.InjectedElement>();
for (Field field : targetClass.getDeclaredFields()) {
AnnotationAttributes annotation = findAutowiredAnnotation(field);
if (annotation != null) {
AnnotationAttributes ann = findAutowiredAnnotation(field);
if (ann != null) {
if (Modifier.isStatic(field.getModifiers())) {
if (logger.isWarnEnabled()) {
logger.warn("Autowired annotation is not supported on static fields: " + field);
}
continue;
}
boolean required = determineRequiredStatus(annotation);
boolean required = determineRequiredStatus(ann);
currElements.add(new AutowiredFieldElement(field, required));
}
}
Expand Down Expand Up @@ -429,9 +429,9 @@ private InjectionMetadata buildAutowiringMetadata(Class<?> clazz) {

private AnnotationAttributes findAutowiredAnnotation(AccessibleObject ao) {
for (Class<? extends Annotation> type : this.autowiredAnnotationTypes) {
AnnotationAttributes annotation = AnnotatedElementUtils.getAnnotationAttributes(ao, type.getName());
if (annotation != null) {
return annotation;
AnnotationAttributes ann = AnnotatedElementUtils.getAnnotationAttributes(ao, type.getName());
if (ann != null) {
return ann;
}
}
return null;
Expand All @@ -442,12 +442,12 @@ private AnnotationAttributes findAutowiredAnnotation(AccessibleObject ao) {
* <p>A 'required' dependency means that autowiring should fail when no beans
* are found. Otherwise, the autowiring process will simply bypass the field
* or method when no beans are found.
* @param annotation the Autowired annotation
* @param ann the Autowired annotation
* @return whether the annotation indicates that a dependency is required
*/
protected boolean determineRequiredStatus(AnnotationAttributes annotation) {
return (!annotation.containsKey(this.requiredParameterName) ||
this.requiredParameterValue == annotation.getBoolean(this.requiredParameterName));
protected boolean determineRequiredStatus(AnnotationAttributes ann) {
return (!ann.containsKey(this.requiredParameterName) ||
this.requiredParameterValue == ann.getBoolean(this.requiredParameterName));
}

/**
Expand Down

0 comments on commit 7317457

Please sign in to comment.