diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java b/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java index 810d935ad3a..2f70f1b6c72 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java @@ -291,20 +291,20 @@ class CglibAopProxy implements AopProxy, Serializable { // unadvised but can return this). May be required to expose the proxy. Callback targetInterceptor; if (exposeProxy) { - targetInterceptor = isStatic ? + targetInterceptor = (isStatic ? new StaticUnadvisedExposedInterceptor(this.advised.getTargetSource().getTarget()) : - new DynamicUnadvisedExposedInterceptor(this.advised.getTargetSource()); + new DynamicUnadvisedExposedInterceptor(this.advised.getTargetSource())); } else { - targetInterceptor = isStatic ? + targetInterceptor = (isStatic ? new StaticUnadvisedInterceptor(this.advised.getTargetSource().getTarget()) : - new DynamicUnadvisedInterceptor(this.advised.getTargetSource()); + new DynamicUnadvisedInterceptor(this.advised.getTargetSource())); } // Choose a "direct to target" dispatcher (used for // unadvised calls to static targets that cannot return this). - Callback targetDispatcher = isStatic ? - new StaticDispatcher(this.advised.getTargetSource().getTarget()) : new SerializableNoOp(); + Callback targetDispatcher = (isStatic ? + new StaticDispatcher(this.advised.getTargetSource().getTarget()) : new SerializableNoOp()); Callback[] mainCallbacks = new Callback[] { aopInterceptor, // for normal advice diff --git a/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java index 1f2e65f113c..67fed08bd91 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -131,7 +131,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher return false; } ControlFlowPointcut that = (ControlFlowPointcut) other; - return (this.clazz.equals(that.clazz)) && ObjectUtils.nullSafeEquals(that.methodName, this.methodName); + return (this.clazz.equals(that.clazz)) && ObjectUtils.nullSafeEquals(this.methodName, that.methodName); } @Override diff --git a/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java b/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java index 30de25c2c1e..adeeb69f31a 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java @@ -144,14 +144,14 @@ public abstract class MethodMatchers { } @Override - public boolean equals(Object obj) { - if (this == obj) { + public boolean equals(Object other) { + if (this == other) { return true; } - if (!(obj instanceof UnionMethodMatcher)) { + if (!(other instanceof UnionMethodMatcher)) { return false; } - UnionMethodMatcher that = (UnionMethodMatcher) obj; + UnionMethodMatcher that = (UnionMethodMatcher) other; return (this.mm1.equals(that.mm1) && this.mm2.equals(that.mm2)); } @@ -231,18 +231,18 @@ public abstract class MethodMatchers { @Override public boolean matches(Method method, @Nullable Class targetClass, boolean hasIntroductions) { - return MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions) && - MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions); + return (MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions) && + MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions)); } @Override public boolean matches(Method method, @Nullable Class targetClass) { - return this.mm1.matches(method, targetClass) && this.mm2.matches(method, targetClass); + return (this.mm1.matches(method, targetClass) && this.mm2.matches(method, targetClass)); } @Override public boolean isRuntime() { - return this.mm1.isRuntime() || this.mm2.isRuntime(); + return (this.mm1.isRuntime() || this.mm2.isRuntime()); } @Override @@ -250,10 +250,10 @@ public abstract class MethodMatchers { // Because a dynamic intersection may be composed of a static and dynamic part, // we must avoid calling the 3-arg matches method on a dynamic matcher, as // it will probably be an unsupported operation. - boolean aMatches = this.mm1.isRuntime() ? - this.mm1.matches(method, targetClass, args) : this.mm1.matches(method, targetClass); - boolean bMatches = this.mm2.isRuntime() ? - this.mm2.matches(method, targetClass, args) : this.mm2.matches(method, targetClass); + boolean aMatches = (this.mm1.isRuntime() ? + this.mm1.matches(method, targetClass, args) : this.mm1.matches(method, targetClass)); + boolean bMatches = (this.mm2.isRuntime() ? + this.mm2.matches(method, targetClass, args) : this.mm2.matches(method, targetClass)); return aMatches && bMatches; } diff --git a/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java b/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java index 8656d9e7023..1e3d72a087c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java +++ b/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java @@ -299,8 +299,7 @@ public class CachedIntrospectionResults { // in particular for Java 8 default methods... Class clazz = beanClass; while (clazz != null && clazz != Object.class) { - Class[] ifcs = clazz.getInterfaces(); - for (Class ifc : ifcs) { + for (Class ifc : clazz.getInterfaces()) { if (!ClassUtils.isJavaLanguageInterface(ifc)) { for (PropertyDescriptor pd : getBeanInfo(ifc).getPropertyDescriptors()) { if (!this.propertyDescriptorCache.containsKey(pd.getName())) { diff --git a/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java b/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java index 64593ad7fa3..88955f386f8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java +++ b/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java @@ -348,14 +348,8 @@ public class MutablePropertyValues implements PropertyValues, Serializable { @Override public boolean equals(Object other) { - if (this == other) { - return true; - } - if (!(other instanceof MutablePropertyValues)) { - return false; - } - MutablePropertyValues that = (MutablePropertyValues) other; - return this.propertyValueList.equals(that.propertyValueList); + return (this == other || (other instanceof MutablePropertyValues && + this.propertyValueList.equals(((MutablePropertyValues) other).propertyValueList))); } @Override diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/CannotLoadBeanClassException.java b/spring-beans/src/main/java/org/springframework/beans/factory/CannotLoadBeanClassException.java index f2a928947df..5d4b35fa3cb 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/CannotLoadBeanClassException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/CannotLoadBeanClassException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,6 @@ public class CannotLoadBeanClassException extends FatalBeanException { @Nullable private String resourceDescription; - @Nullable private String beanName; @Nullable @@ -47,8 +46,8 @@ public class CannotLoadBeanClassException extends FatalBeanException { * @param beanClassName the name of the bean class * @param cause the root cause */ - public CannotLoadBeanClassException( - @Nullable String resourceDescription, String beanName, @Nullable String beanClassName, ClassNotFoundException cause) { + public CannotLoadBeanClassException(@Nullable String resourceDescription, String beanName, + @Nullable String beanClassName, ClassNotFoundException cause) { super("Cannot find class [" + beanClassName + "] for bean with name '" + beanName + "'" + (resourceDescription != null ? " defined in " + resourceDescription : ""), cause); @@ -65,8 +64,8 @@ public class CannotLoadBeanClassException extends FatalBeanException { * @param beanClassName the name of the bean class * @param cause the root cause */ - public CannotLoadBeanClassException( - @Nullable String resourceDescription, String beanName, @Nullable String beanClassName, LinkageError cause) { + public CannotLoadBeanClassException(@Nullable String resourceDescription, String beanName, + @Nullable String beanClassName, LinkageError cause) { super("Error loading class [" + beanClassName + "] for bean with name '" + beanName + "'" + (resourceDescription != null ? " defined in " + resourceDescription : "") + @@ -89,7 +88,6 @@ public class CannotLoadBeanClassException extends FatalBeanException { /** * Return the name of the bean requested. */ - @Nullable public String getBeanName() { return this.beanName; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java index c537ee2f85b..589847ea66d 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java @@ -202,7 +202,7 @@ public class FieldRetrievingFactoryBean } // Try to get the exact method first. - Class targetClass = (this.targetObject != null) ? this.targetObject.getClass() : this.targetClass; + Class targetClass = (this.targetObject != null ? this.targetObject.getClass() : this.targetClass); this.fieldObject = targetClass.getField(this.targetField); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessor.java index 15b162677ab..bedd60051c5 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor { * {@link #postProcessAfterInitialization} callback from the configured * {@link BeanPostProcessor BeanPostProcessors}. *

This callback will only be applied to bean definitions with a bean class. - * In particular, it will not be applied to beans with a "factory-method". + * In particular, it will not be applied to beans with a factory method. *

Post-processors may implement the extended * {@link SmartInstantiationAwareBeanPostProcessor} interface in order * to predict the type of the bean object that they are going to return here. @@ -65,8 +65,8 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor { * @return the bean object to expose instead of a default instance of the target bean, * or {@code null} to proceed with default instantiation * @throws org.springframework.beans.BeansException in case of errors + * @see #postProcessAfterInstantiation * @see org.springframework.beans.factory.support.AbstractBeanDefinition#hasBeanClass - * @see org.springframework.beans.factory.support.AbstractBeanDefinition#getFactoryMethodName */ @Nullable default Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException { @@ -86,6 +86,7 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor { * Returning {@code false} will also prevent any subsequent InstantiationAwareBeanPostProcessor * instances being invoked on this bean instance. * @throws org.springframework.beans.BeansException in case of errors + * @see #postProcessBeforeInstantiation */ default boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException { return true; @@ -104,9 +105,8 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor { * dependency types - which the factory handles specifically - already filtered out) * @param bean the bean instance created, but whose properties have not yet been set * @param beanName the name of the bean - * @return the actual property values to apply to the given bean - * (can be the passed-in PropertyValues instance), or {@code null} - * to skip property population + * @return the actual property values to apply to the given bean (can be the passed-in + * PropertyValues instance), or {@code null} to skip property population * @throws org.springframework.beans.BeansException in case of errors * @see org.springframework.beans.MutablePropertyValues */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessorAdapter.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessorAdapter.java index abe387968c9..1a2c0bf6ef1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessorAdapter.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessorAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ public abstract class InstantiationAwareBeanPostProcessorAdapter implements Smar @Override @Nullable - public Class predictBeanType(Class beanClass, String beanName) { + public Class predictBeanType(Class beanClass, String beanName) throws BeansException { return null; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java index e9435b8349b..a474a0d7918 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java @@ -371,9 +371,9 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp } else if ("ref".equals(name)) { String refName; - if (args[0] == null) + if (args[0] == null) { throw new IllegalArgumentException("Argument to ref() is not a valid bean or was not found"); - + } if (args[0] instanceof RuntimeBeanReference) { refName = ((RuntimeBeanReference) args[0]).getBeanName(); } @@ -489,11 +489,11 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp Map.Entry factoryBeanEntry = (Map.Entry) ((Map) args[0]).entrySet().iterator().next(); // If we have a closure body, that will be the last argument. // In between are the constructor args - int constructorArgsTest = hasClosureArgument?2:1; + int constructorArgsTest = (hasClosureArgument ? 2 : 1); // If we have more than this number of args, we have constructor args if (args.length > constructorArgsTest){ // factory-method requires args - int endOfConstructArgs = (hasClosureArgument? args.length - 1 : args.length); + int endOfConstructArgs = (hasClosureArgument ? args.length - 1 : args.length); this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, null, resolveConstructorArguments(args, 1, endOfConstructArgs)); } @@ -511,7 +511,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp } else { List constructorArgs = resolveConstructorArguments(args, 0, hasClosureArgument ? args.length - 1 : args.length); - currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, null, constructorArgs); + this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, null, constructorArgs); } if (hasClosureArgument) { @@ -545,8 +545,8 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp } /** - * Checks whether there are any {@link RuntimeBeanReference}s inside the {@link Map} - * and converts it to a {@link ManagedMap} if necessary. + * Checks whether there are any {@link RuntimeBeanReference RuntimeBeanReferences} + * inside the {@link Map} and converts it to a {@link ManagedMap} if necessary. * @param map the original Map * @return either the original map or a managed copy of it */ @@ -567,8 +567,8 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp } /** - * Checks whether there are any {@link RuntimeBeanReference}s inside the {@link List} - * and converts it to a {@link ManagedList} if necessary. + * Checks whether there are any {@link RuntimeBeanReference RuntimeBeanReferences} + * inside the {@link List} and converts it to a {@link ManagedList} if necessary. * @param list the original List * @return either the original list or a managed copy of it */ @@ -630,7 +630,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp /** * This method overrides property retrieval in the scope of the - * {@code GroovyBeanDefinitionReader} to either: + * {@code GroovyBeanDefinitionReader}. A property retrieval will either: *