Always use 'this.' when accessing fields
Ensure that `this.` is used consistently when accessing class fields. Issue: SPR-16968
This commit is contained in:
committed by
Juergen Hoeller
parent
eeebd51f57
commit
0b53c1096a
@@ -283,7 +283,7 @@ public class BeanWrapperImpl extends AbstractNestablePropertyAccessor implements
|
||||
@Override
|
||||
@Nullable
|
||||
public TypeDescriptor nested(int level) {
|
||||
return TypeDescriptor.nested(property(pd), level);
|
||||
return TypeDescriptor.nested(property(this.pd), level);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -60,14 +60,14 @@ public class InvalidPropertyException extends FatalBeanException {
|
||||
* Return the offending bean class.
|
||||
*/
|
||||
public Class<?> getBeanClass() {
|
||||
return beanClass;
|
||||
return this.beanClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the offending property.
|
||||
*/
|
||||
public String getPropertyName() {
|
||||
return propertyName;
|
||||
return this.propertyName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -245,10 +245,10 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
ReflectionUtils.doWithMethods(beanClass, method -> {
|
||||
Lookup lookup = method.getAnnotation(Lookup.class);
|
||||
if (lookup != null) {
|
||||
Assert.state(beanFactory != null, "No BeanFactory available");
|
||||
Assert.state(this.beanFactory != null, "No BeanFactory available");
|
||||
LookupOverride override = new LookupOverride(method, lookup.value());
|
||||
try {
|
||||
RootBeanDefinition mbd = (RootBeanDefinition) beanFactory.getMergedBeanDefinition(beanName);
|
||||
RootBeanDefinition mbd = (RootBeanDefinition) this.beanFactory.getMergedBeanDefinition(beanName);
|
||||
mbd.getMethodOverrides().addOverride(override);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
@@ -541,7 +541,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
private Object resolvedCachedArgument(@Nullable String beanName, @Nullable Object cachedArgument) {
|
||||
if (cachedArgument instanceof DependencyDescriptor) {
|
||||
DependencyDescriptor descriptor = (DependencyDescriptor) cachedArgument;
|
||||
Assert.state(beanFactory != null, "No BeanFactory available");
|
||||
Assert.state(this.beanFactory != null, "No BeanFactory available");
|
||||
return this.beanFactory.resolveDependency(descriptor, beanName, null, null);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -205,14 +205,14 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||
final LinkedList<LifecycleElement> currDestroyMethods = new LinkedList<>();
|
||||
|
||||
ReflectionUtils.doWithLocalMethods(targetClass, method -> {
|
||||
if (initAnnotationType != null && method.isAnnotationPresent(initAnnotationType)) {
|
||||
if (this.initAnnotationType != null && method.isAnnotationPresent(this.initAnnotationType)) {
|
||||
LifecycleElement element = new LifecycleElement(method);
|
||||
currInitMethods.add(element);
|
||||
if (debug) {
|
||||
logger.debug("Found init method on class [" + clazz.getName() + "]: " + method);
|
||||
}
|
||||
}
|
||||
if (destroyAnnotationType != null && method.isAnnotationPresent(destroyAnnotationType)) {
|
||||
if (this.destroyAnnotationType != null && method.isAnnotationPresent(this.destroyAnnotationType)) {
|
||||
currDestroyMethods.add(new LifecycleElement(method));
|
||||
if (debug) {
|
||||
logger.debug("Found destroy method on class [" + clazz.getName() + "]: " + method);
|
||||
|
||||
@@ -97,7 +97,7 @@ public class FieldRetrievingFactoryBean
|
||||
*/
|
||||
@Nullable
|
||||
public Class<?> getTargetClass() {
|
||||
return targetClass;
|
||||
return this.targetClass;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -261,7 +261,8 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport
|
||||
@Override
|
||||
@Nullable
|
||||
public String resolvePlaceholder(String placeholderName) {
|
||||
return PropertyPlaceholderConfigurer.this.resolvePlaceholder(placeholderName, props, systemPropertiesMode);
|
||||
return PropertyPlaceholderConfigurer.this.resolvePlaceholder(placeholderName,
|
||||
this.props, systemPropertiesMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -512,7 +512,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) {
|
||||
|
||||
@@ -470,7 +470,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
*/
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return SCOPE_SINGLETON.equals(scope) || SCOPE_DEFAULT.equals(scope);
|
||||
return SCOPE_SINGLETON.equals(this.scope) || SCOPE_DEFAULT.equals(this.scope);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -480,7 +480,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
*/
|
||||
@Override
|
||||
public boolean isPrototype() {
|
||||
return SCOPE_PROTOTYPE.equals(scope);
|
||||
return SCOPE_PROTOTYPE.equals(this.scope);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -275,7 +275,7 @@ public final class BeanDefinitionBuilder {
|
||||
* Set the autowire mode for this definition.
|
||||
*/
|
||||
public BeanDefinitionBuilder setAutowireMode(int autowireMode) {
|
||||
beanDefinition.setAutowireMode(autowireMode);
|
||||
this.beanDefinition.setAutowireMode(autowireMode);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ public final class BeanDefinitionBuilder {
|
||||
* Set the depency check mode for this definition.
|
||||
*/
|
||||
public BeanDefinitionBuilder setDependencyCheck(int dependencyCheck) {
|
||||
beanDefinition.setDependencyCheck(dependencyCheck);
|
||||
this.beanDefinition.setDependencyCheck(dependencyCheck);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ public final class BeanDefinitionBuilder {
|
||||
*/
|
||||
public BeanDefinitionBuilder applyCustomizers(BeanDefinitionCustomizer... customizers) {
|
||||
for (BeanDefinitionCustomizer customizer : customizers) {
|
||||
customizer.customize(beanDefinition);
|
||||
customizer.customize(this.beanDefinition);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -261,15 +261,15 @@ class ConstructorResolver {
|
||||
}
|
||||
|
||||
try {
|
||||
final InstantiationStrategy strategy = beanFactory.getInstantiationStrategy();
|
||||
final InstantiationStrategy strategy = this.beanFactory.getInstantiationStrategy();
|
||||
Object beanInstance;
|
||||
|
||||
if (System.getSecurityManager() != null) {
|
||||
final Constructor<?> ctorToUse = constructorToUse;
|
||||
final Object[] argumentsToUse = argsToUse;
|
||||
beanInstance = AccessController.doPrivileged((PrivilegedAction<Object>) () ->
|
||||
strategy.instantiate(mbd, beanName, beanFactory, ctorToUse, argumentsToUse),
|
||||
beanFactory.getAccessControlContext());
|
||||
strategy.instantiate(mbd, beanName, this.beanFactory, ctorToUse, argumentsToUse),
|
||||
this.beanFactory.getAccessControlContext());
|
||||
}
|
||||
else {
|
||||
beanInstance = strategy.instantiate(mbd, beanName, this.beanFactory, constructorToUse, argsToUse);
|
||||
@@ -575,8 +575,8 @@ class ConstructorResolver {
|
||||
final Method factoryMethod = factoryMethodToUse;
|
||||
final Object[] args = argsToUse;
|
||||
beanInstance = AccessController.doPrivileged((PrivilegedAction<Object>) () ->
|
||||
beanFactory.getInstantiationStrategy().instantiate(mbd, beanName, beanFactory, fb, factoryMethod, args),
|
||||
beanFactory.getAccessControlContext());
|
||||
this.beanFactory.getInstantiationStrategy().instantiate(mbd, beanName, this.beanFactory, fb, factoryMethod, args),
|
||||
this.beanFactory.getAccessControlContext());
|
||||
}
|
||||
else {
|
||||
beanInstance = this.beanFactory.getInstantiationStrategy().instantiate(
|
||||
|
||||
@@ -1656,7 +1656,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
return createOptionalDependency(this.descriptor, this.beanName, args);
|
||||
}
|
||||
else {
|
||||
DependencyDescriptor descriptorToUse = new DependencyDescriptor(descriptor) {
|
||||
DependencyDescriptor descriptorToUse = new DependencyDescriptor(this.descriptor) {
|
||||
@Override
|
||||
public Object resolveCandidate(String beanName, Class<?> requiredType, BeanFactory beanFactory) {
|
||||
return beanFactory.getBean(beanName, args);
|
||||
@@ -1677,7 +1677,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
return createOptionalDependency(this.descriptor, this.beanName);
|
||||
}
|
||||
else {
|
||||
DependencyDescriptor descriptorToUse = new DependencyDescriptor(descriptor) {
|
||||
DependencyDescriptor descriptorToUse = new DependencyDescriptor(this.descriptor) {
|
||||
@Override
|
||||
public boolean isRequired() {
|
||||
return false;
|
||||
@@ -1690,7 +1690,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getIfUnique() throws BeansException {
|
||||
DependencyDescriptor descriptorToUse = new DependencyDescriptor(descriptor) {
|
||||
DependencyDescriptor descriptorToUse = new DependencyDescriptor(this.descriptor) {
|
||||
@Override
|
||||
public boolean isRequired() {
|
||||
return false;
|
||||
|
||||
@@ -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.
|
||||
@@ -248,12 +248,12 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
try {
|
||||
if (System.getSecurityManager() != null) {
|
||||
AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () -> {
|
||||
((DisposableBean) bean).destroy();
|
||||
((DisposableBean) this.bean).destroy();
|
||||
return null;
|
||||
}, acc);
|
||||
}, this.acc);
|
||||
}
|
||||
else {
|
||||
((DisposableBean) bean).destroy();
|
||||
((DisposableBean) this.bean).destroy();
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
@@ -326,7 +326,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
});
|
||||
try {
|
||||
AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () ->
|
||||
destroyMethod.invoke(bean, args), acc);
|
||||
destroyMethod.invoke(this.bean, args), this.acc);
|
||||
}
|
||||
catch (PrivilegedActionException pax) {
|
||||
throw (InvocationTargetException) pax.getException();
|
||||
@@ -334,7 +334,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
}
|
||||
else {
|
||||
ReflectionUtils.makeAccessible(destroyMethod);
|
||||
destroyMethod.invoke(bean, args);
|
||||
destroyMethod.invoke(this.bean, args);
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException ex) {
|
||||
|
||||
@@ -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.
|
||||
@@ -56,7 +56,7 @@ public class SimpleSecurityContextProvider implements SecurityContextProvider {
|
||||
|
||||
@Override
|
||||
public AccessControlContext getAccessControlContext() {
|
||||
return (this.acc != null ? acc : AccessController.getContext());
|
||||
return (this.acc != null ? this.acc : AccessController.getContext());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
String[] array = StringUtils.delimitedListToStringArray(text, this.separator, this.charsToDelete);
|
||||
if (trimValues) {
|
||||
if (this.trimValues) {
|
||||
array = StringUtils.trimArrayElements(array);
|
||||
}
|
||||
if (this.emptyArrayAsNull && array.length == 0) {
|
||||
|
||||
Reference in New Issue
Block a user