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: *
NOTE: We highly recommend passing a long-lived, pre-configured
* {@code ReactiveAdapterRegistry} instance for customization purposes.
* This accessor is only meant as a fallback for code paths that want to
* fall back on a default instance if one isn't provided.
- *
* @return the shared {@code ReactiveAdapterRegistry} instance (never {@code null})
* @since 5.0.2
*/
@@ -191,7 +189,6 @@ public class ReactiveAdapterRegistry {
private static class ReactorRegistrar {
void registerAdapters(ReactiveAdapterRegistry registry) {
-
// Register Flux and Mono before Publisher...
registry.registerReactiveType(
@@ -280,7 +277,6 @@ public class ReactiveAdapterRegistry {
private static class ReactorJdkFlowAdapterRegistrar {
void registerAdapter(ReactiveAdapterRegistry registry) throws Exception {
-
// TODO: remove reflection when build requires JDK 9+
String publisherName = "java.util.concurrent.Flow.Publisher";
diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/ConversionUtils.java b/spring-core/src/main/java/org/springframework/core/convert/support/ConversionUtils.java
index 7e6b25fe9a3..90399bf7f48 100644
--- a/spring-core/src/main/java/org/springframework/core/convert/support/ConversionUtils.java
+++ b/spring-core/src/main/java/org/springframework/core/convert/support/ConversionUtils.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.
@@ -62,14 +62,12 @@ abstract class ConversionUtils {
// yes
return true;
}
- else if (sourceElementType.getType().isAssignableFrom(targetElementType.getType())) {
+ if (sourceElementType.getType().isAssignableFrom(targetElementType.getType())) {
// maybe
return true;
}
- else {
- // no
- return false;
- }
+ // no
+ return false;
}
public static Class> getEnumType(Class> targetType) {
diff --git a/spring-core/src/main/java/org/springframework/core/env/PropertySource.java b/spring-core/src/main/java/org/springframework/core/env/PropertySource.java
index a983fff3ff8..ef16096e3c3 100644
--- a/spring-core/src/main/java/org/springframework/core/env/PropertySource.java
+++ b/spring-core/src/main/java/org/springframework/core/env/PropertySource.java
@@ -131,9 +131,9 @@ public abstract class PropertySource No properties other than {@code name} are evaluated.
*/
@Override
- public boolean equals(Object obj) {
- return (this == obj || (obj instanceof PropertySource &&
- ObjectUtils.nullSafeEquals(this.name, ((PropertySource>) obj).name)));
+ public boolean equals(Object other) {
+ return (this == other || (other instanceof PropertySource &&
+ ObjectUtils.nullSafeEquals(this.name, ((PropertySource>) other).name)));
}
/**
diff --git a/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java b/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java
index 6beef08a30d..e02cfcb7902 100644
--- a/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java
+++ b/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java
@@ -209,23 +209,14 @@ public abstract class AbstractResource implements Resource {
}
- /**
- * This implementation returns the description of this resource.
- * @see #getDescription()
- */
- @Override
- public String toString() {
- return getDescription();
- }
-
/**
* This implementation compares description strings.
* @see #getDescription()
*/
@Override
- public boolean equals(Object obj) {
- return (obj == this ||
- (obj instanceof Resource && ((Resource) obj).getDescription().equals(getDescription())));
+ public boolean equals(Object other) {
+ return (this == other || (other instanceof Resource &&
+ ((Resource) other).getDescription().equals(getDescription())));
}
/**
@@ -237,4 +228,13 @@ public abstract class AbstractResource implements Resource {
return getDescription().hashCode();
}
+ /**
+ * This implementation returns the description of this resource.
+ * @see #getDescription()
+ */
+ @Override
+ public String toString() {
+ return getDescription();
+ }
+
}
diff --git a/spring-core/src/main/java/org/springframework/core/io/ByteArrayResource.java b/spring-core/src/main/java/org/springframework/core/io/ByteArrayResource.java
index 79415fa42c0..034c9e4b5df 100644
--- a/spring-core/src/main/java/org/springframework/core/io/ByteArrayResource.java
+++ b/spring-core/src/main/java/org/springframework/core/io/ByteArrayResource.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.
@@ -115,9 +115,9 @@ public class ByteArrayResource extends AbstractResource {
* @see java.util.Arrays#equals(byte[], byte[])
*/
@Override
- public boolean equals(Object obj) {
- return (obj == this ||
- (obj instanceof ByteArrayResource && Arrays.equals(((ByteArrayResource) obj).byteArray, this.byteArray)));
+ public boolean equals(Object other) {
+ return (this == other || (other instanceof ByteArrayResource &&
+ Arrays.equals(((ByteArrayResource) other).byteArray, this.byteArray)));
}
/**
diff --git a/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java b/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java
index be203770a69..863b5dbe682 100644
--- a/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java
+++ b/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java
@@ -244,17 +244,17 @@ public class ClassPathResource extends AbstractFileResolvingResource {
* This implementation compares the underlying class path locations.
*/
@Override
- public boolean equals(Object obj) {
- if (obj == this) {
+ public boolean equals(Object other) {
+ if (this == other) {
return true;
}
- if (obj instanceof ClassPathResource) {
- ClassPathResource otherRes = (ClassPathResource) obj;
- return (this.path.equals(otherRes.path) &&
- ObjectUtils.nullSafeEquals(this.classLoader, otherRes.classLoader) &&
- ObjectUtils.nullSafeEquals(this.clazz, otherRes.clazz));
+ if (!(other instanceof ClassPathResource)) {
+ return false;
}
- return false;
+ ClassPathResource otherRes = (ClassPathResource) other;
+ return (this.path.equals(otherRes.path) &&
+ ObjectUtils.nullSafeEquals(this.classLoader, otherRes.classLoader) &&
+ ObjectUtils.nullSafeEquals(this.clazz, otherRes.clazz));
}
/**
diff --git a/spring-core/src/main/java/org/springframework/core/io/DescriptiveResource.java b/spring-core/src/main/java/org/springframework/core/io/DescriptiveResource.java
index 127db9f767a..e42457365f2 100644
--- a/spring-core/src/main/java/org/springframework/core/io/DescriptiveResource.java
+++ b/spring-core/src/main/java/org/springframework/core/io/DescriptiveResource.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.
@@ -72,9 +72,9 @@ public class DescriptiveResource extends AbstractResource {
* This implementation compares the underlying description String.
*/
@Override
- public boolean equals(Object obj) {
- return (obj == this ||
- (obj instanceof DescriptiveResource && ((DescriptiveResource) obj).description.equals(this.description)));
+ public boolean equals(Object other) {
+ return (this == other || (other instanceof DescriptiveResource &&
+ ((DescriptiveResource) other).description.equals(this.description)));
}
/**
diff --git a/spring-core/src/main/java/org/springframework/core/io/FileSystemResource.java b/spring-core/src/main/java/org/springframework/core/io/FileSystemResource.java
index 4f17630776b..50d41bd72df 100644
--- a/spring-core/src/main/java/org/springframework/core/io/FileSystemResource.java
+++ b/spring-core/src/main/java/org/springframework/core/io/FileSystemResource.java
@@ -250,9 +250,9 @@ public class FileSystemResource extends AbstractResource implements WritableReso
* This implementation compares the underlying File references.
*/
@Override
- public boolean equals(Object obj) {
- return (obj == this ||
- (obj instanceof FileSystemResource && this.path.equals(((FileSystemResource) obj).path)));
+ public boolean equals(Object other) {
+ return (this == other || (other instanceof FileSystemResource &&
+ this.path.equals(((FileSystemResource) other).path)));
}
/**
diff --git a/spring-core/src/main/java/org/springframework/core/io/InputStreamResource.java b/spring-core/src/main/java/org/springframework/core/io/InputStreamResource.java
index b6470b5a8d2..37ea6b6ee60 100644
--- a/spring-core/src/main/java/org/springframework/core/io/InputStreamResource.java
+++ b/spring-core/src/main/java/org/springframework/core/io/InputStreamResource.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.
@@ -115,9 +115,9 @@ public class InputStreamResource extends AbstractResource {
* This implementation compares the underlying InputStream.
*/
@Override
- public boolean equals(Object obj) {
- return (obj == this ||
- (obj instanceof InputStreamResource && ((InputStreamResource) obj).inputStream.equals(this.inputStream)));
+ public boolean equals(Object other) {
+ return (this == other || (other instanceof InputStreamResource &&
+ ((InputStreamResource) other).inputStream.equals(this.inputStream)));
}
/**
diff --git a/spring-core/src/main/java/org/springframework/core/io/PathResource.java b/spring-core/src/main/java/org/springframework/core/io/PathResource.java
index 23a947c06d8..3eb633af1c5 100644
--- a/spring-core/src/main/java/org/springframework/core/io/PathResource.java
+++ b/spring-core/src/main/java/org/springframework/core/io/PathResource.java
@@ -268,9 +268,9 @@ public class PathResource extends AbstractResource implements WritableResource {
* This implementation compares the underlying Path references.
*/
@Override
- public boolean equals(Object obj) {
- return (this == obj ||
- (obj instanceof PathResource && this.path.equals(((PathResource) obj).path)));
+ public boolean equals(Object other) {
+ return (this == other || (other instanceof PathResource &&
+ this.path.equals(((PathResource) other).path)));
}
/**
diff --git a/spring-core/src/main/java/org/springframework/core/io/UrlResource.java b/spring-core/src/main/java/org/springframework/core/io/UrlResource.java
index 37373a22d71..72945507b49 100644
--- a/spring-core/src/main/java/org/springframework/core/io/UrlResource.java
+++ b/spring-core/src/main/java/org/springframework/core/io/UrlResource.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.
@@ -261,9 +261,9 @@ public class UrlResource extends AbstractFileResolvingResource {
* This implementation compares the underlying URL references.
*/
@Override
- public boolean equals(Object obj) {
- return (obj == this ||
- (obj instanceof UrlResource && this.cleanedUrl.equals(((UrlResource) obj).cleanedUrl)));
+ public boolean equals(Object other) {
+ return (this == other || (other instanceof UrlResource &&
+ this.cleanedUrl.equals(((UrlResource) other).cleanedUrl)));
}
/**
diff --git a/spring-core/src/main/java/org/springframework/core/io/VfsResource.java b/spring-core/src/main/java/org/springframework/core/io/VfsResource.java
index 296e8423655..267a906db9f 100644
--- a/spring-core/src/main/java/org/springframework/core/io/VfsResource.java
+++ b/spring-core/src/main/java/org/springframework/core/io/VfsResource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2015 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.
@@ -125,8 +125,9 @@ public class VfsResource extends AbstractResource {
}
@Override
- public boolean equals(Object obj) {
- return (obj == this || (obj instanceof VfsResource && this.resource.equals(((VfsResource) obj).resource)));
+ public boolean equals(Object other) {
+ return (this == other || (other instanceof VfsResource &&
+ this.resource.equals(((VfsResource) other).resource)));
}
@Override
diff --git a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBuffer.java b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBuffer.java
index 072e24a7337..c78102e108c 100644
--- a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBuffer.java
+++ b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBuffer.java
@@ -57,22 +57,22 @@ public interface DataBuffer {
DataBufferFactory factory();
/**
- * Return the index of the first byte in this buffer that matches the given
- * predicate.
+ * Return the index of the first byte in this buffer that matches
+ * the given predicate.
* @param predicate the predicate to match
* @param fromIndex the index to start the search from
- * @return the index of the first byte that matches {@code predicate}; or {@code -1}
- * if none match
+ * @return the index of the first byte that matches {@code predicate};
+ * or {@code -1} if none match
*/
int indexOf(IntPredicate predicate, int fromIndex);
/**
- * Return the index of the last byte in this buffer that matches the given
- * predicate.
+ * Return the index of the last byte in this buffer that matches
+ * the given predicate.
* @param predicate the predicate to match
* @param fromIndex the index to start the search from
- * @return the index of the last byte that matches {@code predicate}; or {@code -1}
- * if none match
+ * @return the index of the last byte that matches {@code predicate};
+ * or {@code -1} if none match
*/
int lastIndexOf(IntPredicate predicate, int fromIndex);
@@ -97,9 +97,10 @@ public interface DataBuffer {
int capacity();
/**
- * Sets the number of bytes that this buffer can contain. If the new capacity is lower than
- * the current capacity, the contents of this buffer will be truncated. If the new capacity
- * is higher than the current capacity, it will be expanded.
+ * Set the number of bytes that this buffer can contain.
+ * If the new capacity is lower than the current capacity, the contents
+ * of this buffer will be truncated. If the new capacity is higher than
+ * the current capacity, it will be expanded.
* @param capacity the new capacity
* @return this buffer
*/
@@ -116,8 +117,8 @@ public interface DataBuffer {
* Set the position from which this buffer will read.
* @param readPosition the new read position
* @return this buffer
- * @throws IndexOutOfBoundsException if {@code readPosition} is smaller than 0 or greater than
- * {@link #writePosition()}
+ * @throws IndexOutOfBoundsException if {@code readPosition} is smaller than 0
+ * or greater than {@link #writePosition()}
* @since 5.0.1
*/
DataBuffer readPosition(int readPosition);
diff --git a/spring-core/src/main/java/org/springframework/core/io/buffer/DefaultDataBuffer.java b/spring-core/src/main/java/org/springframework/core/io/buffer/DefaultDataBuffer.java
index 699e74f110e..b51b3f42ae1 100644
--- a/spring-core/src/main/java/org/springframework/core/io/buffer/DefaultDataBuffer.java
+++ b/spring-core/src/main/java/org/springframework/core/io/buffer/DefaultDataBuffer.java
@@ -27,14 +27,13 @@ import java.util.function.IntPredicate;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
-
/**
* Default implementation of the {@link DataBuffer} interface that uses a
* {@link ByteBuffer} internally. with separate read and write positions.
* Constructed using the {@link DefaultDataBufferFactory}.
*
- * Inspired by Netty's {@code ByteBuf}. Introduced so that non-Netty runtimes (i.e. Servlet)
- * do not require Netty on the classpath.
+ * Inspired by Netty's {@code ByteBuf}. Introduced so that non-Netty runtimes
+ * (i.e. Servlet) do not require Netty on the classpath.
*
* @author Arjen Poutsma
* @author Juergen Hoeller
@@ -52,32 +51,29 @@ public class DefaultDataBuffer implements DataBuffer {
private ByteBuffer byteBuffer;
+ private int capacity;
+
private int readPosition;
private int writePosition;
- private int capacity;
private DefaultDataBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer) {
- Assert.notNull(dataBufferFactory, "'dataBufferFactory' must not be null");
- Assert.notNull(byteBuffer, "'byteBuffer' must not be null");
-
+ Assert.notNull(dataBufferFactory, "DefaultDataBufferFactory must not be null");
+ Assert.notNull(byteBuffer, "ByteBuffer must not be null");
this.dataBufferFactory = dataBufferFactory;
ByteBuffer slice = byteBuffer.slice();
this.byteBuffer = slice;
this.capacity = slice.remaining();
}
- static DefaultDataBuffer fromFilledByteBuffer(DefaultDataBufferFactory dataBufferFactory,
- ByteBuffer byteBuffer) {
-
+ static DefaultDataBuffer fromFilledByteBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer) {
DefaultDataBuffer dataBuffer = new DefaultDataBuffer(dataBufferFactory, byteBuffer);
dataBuffer.writePosition(byteBuffer.remaining());
return dataBuffer;
}
- static DefaultDataBuffer fromEmptyByteBuffer(DefaultDataBufferFactory dataBufferFactory,
- ByteBuffer byteBuffer) {
+ static DefaultDataBuffer fromEmptyByteBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer) {
return new DefaultDataBuffer(dataBufferFactory, byteBuffer);
}
@@ -95,6 +91,7 @@ public class DefaultDataBuffer implements DataBuffer {
this.capacity = byteBuffer.remaining();
}
+
@Override
public DefaultDataBufferFactory factory() {
return this.dataBufferFactory;
@@ -413,17 +410,17 @@ public class DefaultDataBuffer implements DataBuffer {
@Override
- public boolean equals(Object obj) {
- if (this == obj) {
+ public boolean equals(Object other) {
+ if (this == other) {
return true;
}
- if (!(obj instanceof DefaultDataBuffer)) {
+ if (!(other instanceof DefaultDataBuffer)) {
return false;
}
- DefaultDataBuffer other = (DefaultDataBuffer) obj;
- return (this.readPosition == other.readPosition &&
- this.writePosition == other.writePosition &&
- this.byteBuffer.equals(other.byteBuffer));
+ DefaultDataBuffer otherBuffer = (DefaultDataBuffer) other;
+ return (this.readPosition == otherBuffer.readPosition &&
+ this.writePosition == otherBuffer.writePosition &&
+ this.byteBuffer.equals(otherBuffer.byteBuffer));
}
@Override
@@ -433,10 +430,11 @@ public class DefaultDataBuffer implements DataBuffer {
@Override
public String toString() {
- return String.format("DefaultDataBuffer (r: %d, w %d, c %d)", this.readPosition,
- this.writePosition, this.capacity);
+ return String.format("DefaultDataBuffer (r: %d, w %d, c %d)",
+ this.readPosition, this.writePosition, this.capacity);
}
+
private void checkIndex(int index, int length) {
assertIndex(index >= 0, "index %d must be >= 0", index);
assertIndex(length >= 0, "length %d must be >= 0", index);
@@ -451,6 +449,7 @@ public class DefaultDataBuffer implements DataBuffer {
}
}
+
private class DefaultDataBufferInputStream extends InputStream {
@Override
@@ -478,7 +477,6 @@ public class DefaultDataBuffer implements DataBuffer {
}
-
private class DefaultDataBufferOutputStream extends OutputStream {
@Override
@@ -495,16 +493,14 @@ public class DefaultDataBuffer implements DataBuffer {
private static class SlicedDefaultDataBuffer extends DefaultDataBuffer {
- SlicedDefaultDataBuffer(ByteBuffer byteBuffer, DefaultDataBufferFactory dataBufferFactory,
- int length) {
+ SlicedDefaultDataBuffer(ByteBuffer byteBuffer, DefaultDataBufferFactory dataBufferFactory, int length) {
super(dataBufferFactory, byteBuffer);
writePosition(length);
}
@Override
public DefaultDataBuffer capacity(int newCapacity) {
- throw new UnsupportedOperationException(
- "Changing the capacity of a sliced buffer is not supported");
+ throw new UnsupportedOperationException("Changing the capacity of a sliced buffer is not supported");
}
}
diff --git a/spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBuffer.java b/spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBuffer.java
index cde0e9a03ec..2e6f6c89318 100644
--- a/spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBuffer.java
+++ b/spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBuffer.java
@@ -37,19 +37,18 @@ import org.springframework.util.Assert;
*/
public class NettyDataBuffer implements PooledDataBuffer {
- private final NettyDataBufferFactory dataBufferFactory;
-
private final ByteBuf byteBuf;
+ private final NettyDataBufferFactory dataBufferFactory;
+
/**
* Creates a new {@code NettyDataBuffer} based on the given {@code ByteBuff}.
* @param byteBuf the buffer to base this buffer on
*/
NettyDataBuffer(ByteBuf byteBuf, NettyDataBufferFactory dataBufferFactory) {
- Assert.notNull(byteBuf, "'byteBuf' must not be null");
- Assert.notNull(dataBufferFactory, "'dataBufferFactory' must not be null");
-
+ Assert.notNull(byteBuf, "ByteBuf must not be null");
+ Assert.notNull(dataBufferFactory, "NettyDataBufferFactory must not be null");
this.byteBuf = byteBuf;
this.dataBufferFactory = dataBufferFactory;
}
@@ -272,15 +271,9 @@ public class NettyDataBuffer implements PooledDataBuffer {
@Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof NettyDataBuffer)) {
- return false;
- }
- NettyDataBuffer other = (NettyDataBuffer) obj;
- return this.byteBuf.equals(other.byteBuf);
+ public boolean equals(Object other) {
+ return (this == other || (other instanceof NettyDataBuffer &&
+ this.byteBuf.equals(((NettyDataBuffer) other).byteBuf)));
}
@Override
diff --git a/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java b/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java
index e0502f7ce66..b14a08c2fc9 100644
--- a/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java
+++ b/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java
@@ -833,12 +833,12 @@ public class ConcurrentReferenceHashMap