diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java b/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java index 5425d640b5c..d18b1ed1eac 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java @@ -396,7 +396,7 @@ public abstract class BeanUtils { * @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"); @@ -610,7 +610,7 @@ public abstract class BeanUtils { 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(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java index f5a9e464a0c..49a0b88f421 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java @@ -236,8 +236,8 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean 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 + @@ -248,7 +248,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean 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, @@ -322,9 +322,9 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean private InjectionMetadata findAutowiringMetadata(String beanName, Class clazz) { - // Quick check on the concurrent map first, with minimal locking. // Fall back to class name as cache key, for backwards compatibility with custom callers. String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName()); + // Quick check on the concurrent map first, with minimal locking. InjectionMetadata metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { synchronized (this.injectionMetadataCache) { @@ -345,15 +345,15 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean do { LinkedList currElements = new LinkedList(); 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)); } } @@ -390,9 +390,9 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean private AnnotationAttributes findAutowiredAnnotation(AccessibleObject ao) { for (Class 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; @@ -403,12 +403,12 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean *

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)); } /** diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java b/spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java index 88c6ef076c4..6ccaeebc285 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java @@ -401,10 +401,9 @@ public class PersistenceAnnotationBeanPostProcessor } for (Method method : targetClass.getDeclaredMethods()) { method = BridgeMethodResolver.findBridgedMethod(method); - Method mostSpecificMethod = BridgeMethodResolver.findBridgedMethod(ClassUtils.getMostSpecificMethod(method, clazz)); if ((method.isAnnotationPresent(PersistenceContext.class) || method.isAnnotationPresent(PersistenceUnit.class)) && - method.equals(mostSpecificMethod)) { + method.equals(BridgeMethodResolver.findBridgedMethod(ClassUtils.getMostSpecificMethod(method, clazz)))) { if (Modifier.isStatic(method.getModifiers())) { throw new IllegalStateException("Persistence annotations are not supported on static methods"); }