parent
3e64388b20
commit
a631af80c1
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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())) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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}.
|
||||
* <p>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.
|
||||
* <p>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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
* <ul>
|
||||
* <li>Retrieve a variable from the bean builder's binding if it exists
|
||||
* <li>Retrieve a RuntimeBeanReference for a specific bean if it exists
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -82,7 +82,7 @@ public final class ParseState {
|
|||
*/
|
||||
@Nullable
|
||||
public Entry peek() {
|
||||
return this.state.isEmpty() ? null : this.state.peek();
|
||||
return this.state.peek();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 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.
|
||||
|
|
@ -80,10 +80,9 @@ class BeanDefinitionResource extends AbstractResource {
|
|||
* This implementation compares the underlying BeanDefinition.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj == this ||
|
||||
(obj instanceof BeanDefinitionResource &&
|
||||
((BeanDefinitionResource) obj).beanDefinition.equals(this.beanDefinition)));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof BeanDefinitionResource &&
|
||||
((BeanDefinitionResource) other).beanDefinition.equals(this.beanDefinition)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1521,8 +1521,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
|||
isAutowireCandidate(beanName, mbd, descriptor, getAutowireCandidateResolver())) {
|
||||
// Probably a proxy interfering with target type match -> throw meaningful exception.
|
||||
Object beanInstance = getSingleton(beanName, false);
|
||||
Class<?> beanType = (beanInstance != null && beanInstance.getClass() != NullBean.class) ?
|
||||
beanInstance.getClass() : predictBeanType(beanName, mbd);
|
||||
Class<?> beanType = (beanInstance != null && beanInstance.getClass() != NullBean.class ?
|
||||
beanInstance.getClass() : predictBeanType(beanName, mbd));
|
||||
if (beanType != null && !type.isAssignableFrom(beanType)) {
|
||||
throw new BeanNotOfRequiredTypeException(beanName, type, beanType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -900,9 +900,9 @@ public class BeanDefinitionParserDelegate {
|
|||
*/
|
||||
@Nullable
|
||||
public Object parsePropertyValue(Element ele, BeanDefinition bd, @Nullable String propertyName) {
|
||||
String elementName = (propertyName != null) ?
|
||||
"<property> element for property '" + propertyName + "'" :
|
||||
"<constructor-arg> element";
|
||||
String elementName = (propertyName != null ?
|
||||
"<property> element for property '" + propertyName + "'" :
|
||||
"<constructor-arg> element");
|
||||
|
||||
// Should only have one child element: ref, value, list, etc.
|
||||
NodeList nl = ele.getChildNodes();
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -46,8 +46,7 @@ import javax.lang.model.element.TypeElement;
|
|||
public class CandidateComponentsIndexer implements Processor {
|
||||
|
||||
private static final Set<ElementKind> TYPE_KINDS =
|
||||
Collections.unmodifiableSet(EnumSet.of(ElementKind.CLASS,
|
||||
ElementKind.INTERFACE));
|
||||
Collections.unmodifiableSet(EnumSet.of(ElementKind.CLASS, ElementKind.INTERFACE));
|
||||
|
||||
private MetadataStore metadataStore;
|
||||
|
||||
|
|
@ -135,10 +134,10 @@ public class CandidateComponentsIndexer implements Processor {
|
|||
|
||||
private static List<TypeElement> staticTypesIn(Iterable<? extends Element> elements) {
|
||||
List<TypeElement> list = new ArrayList<>();
|
||||
for (Element e : elements) {
|
||||
if (TYPE_KINDS.contains(e.getKind())
|
||||
&& e.getModifiers().contains(Modifier.STATIC))
|
||||
list.add(TypeElement.class.cast(e));
|
||||
for (Element element : elements) {
|
||||
if (TYPE_KINDS.contains(element.getKind()) && element.getModifiers().contains(Modifier.STATIC)) {
|
||||
list.add(TypeElement.class.cast(element));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.springframework.cache.jcache.interceptor;
|
|||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
|
@ -32,13 +33,12 @@ import org.springframework.cache.interceptor.CacheResolver;
|
|||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ExceptionTypeFilter;
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
|
||||
/**
|
||||
* A base {@link JCacheOperation} implementation.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 4.1
|
||||
* @param <A> the annotation type
|
||||
*/
|
||||
abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOperation<A> {
|
||||
|
||||
|
|
@ -55,8 +55,8 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
|||
* @param cacheResolver the cache resolver to resolve regular caches
|
||||
*/
|
||||
protected AbstractJCacheOperation(CacheMethodDetails<A> methodDetails, CacheResolver cacheResolver) {
|
||||
Assert.notNull(methodDetails, "method details must not be null.");
|
||||
Assert.notNull(cacheResolver, "cache resolver must not be null.");
|
||||
Assert.notNull(methodDetails, "CacheMethodDetails must not be null");
|
||||
Assert.notNull(cacheResolver, "CacheResolver must not be null");
|
||||
this.methodDetails = methodDetails;
|
||||
this.cacheResolver = cacheResolver;
|
||||
this.allParameterDetails = initializeAllParameterDetails(methodDetails.getMethod());
|
||||
|
|
@ -116,7 +116,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
|||
protected ExceptionTypeFilter createExceptionTypeFilter(
|
||||
Class<? extends Throwable>[] includes, Class<? extends Throwable>[] excludes) {
|
||||
|
||||
return new ExceptionTypeFilter(asList(includes), asList(excludes), true);
|
||||
return new ExceptionTypeFilter(Arrays.asList(includes), Arrays.asList(excludes), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -147,6 +147,9 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Details for a single cache parameter.
|
||||
*/
|
||||
protected static class CacheParameterDetail {
|
||||
|
||||
private final Class<?> rawType;
|
||||
|
|
@ -196,6 +199,9 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* A single cache invocation parameter.
|
||||
*/
|
||||
protected static class CacheInvocationParameterImpl implements CacheInvocationParameter {
|
||||
|
||||
private final CacheParameterDetail detail;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -18,18 +18,18 @@ package org.springframework.cache.jcache.interceptor;
|
|||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
|
||||
/**
|
||||
* The default {@link CacheMethodDetails} implementation.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 4.1
|
||||
* @param <A> the annotation type
|
||||
*/
|
||||
class DefaultCacheMethodDetails<A extends Annotation> implements CacheMethodDetails<A> {
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ class DefaultCacheMethodDetails<A extends Annotation> implements CacheMethodDeta
|
|||
public DefaultCacheMethodDetails(Method method, A cacheAnnotation, String cacheName) {
|
||||
this.method = method;
|
||||
this.annotations = Collections.unmodifiableSet(
|
||||
new LinkedHashSet<>(asList(method.getAnnotations())));
|
||||
new LinkedHashSet<>(Arrays.asList(method.getAnnotations())));
|
||||
this.cacheAnnotation = cacheAnnotation;
|
||||
this.cacheName = cacheName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -151,7 +151,7 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T
|
|||
return 0;
|
||||
}
|
||||
long diff = getDelay(TimeUnit.MILLISECONDS) - other.getDelay(TimeUnit.MILLISECONDS);
|
||||
return (diff == 0 ? 0 : ((diff < 0)? -1 : 1));
|
||||
return (diff == 0 ? 0 : ((diff < 0) ? -1 : 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -753,7 +753,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
|
|||
|
||||
@Override
|
||||
public Class<? extends Scheduler> getObjectType() {
|
||||
return (this.scheduler != null) ? this.scheduler.getClass() : Scheduler.class;
|
||||
return (this.scheduler != null ? this.scheduler.getClass() : Scheduler.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -32,9 +32,12 @@ import org.springframework.util.StringUtils;
|
|||
@SuppressWarnings("serial")
|
||||
public class SimpleKey implements Serializable {
|
||||
|
||||
/** An empty key. */
|
||||
public static final SimpleKey EMPTY = new SimpleKey();
|
||||
|
||||
|
||||
private final Object[] params;
|
||||
|
||||
private final int hashCode;
|
||||
|
||||
|
||||
|
|
@ -49,10 +52,11 @@ public class SimpleKey implements Serializable {
|
|||
this.hashCode = Arrays.deepHashCode(this.params);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (this == obj || (obj instanceof SimpleKey
|
||||
&& Arrays.deepEquals(this.params, ((SimpleKey) obj).params)));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other ||
|
||||
(other instanceof SimpleKey && Arrays.deepEquals(this.params, ((SimpleKey) other).params)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@ import org.springframework.util.ClassUtils;
|
|||
* @author Stephane Nicoll
|
||||
* @since 2.5
|
||||
* @see ContextAnnotationAutowireCandidateResolver
|
||||
* @see CommonAnnotationBeanPostProcessor
|
||||
* @see ConfigurationClassPostProcessor
|
||||
* @see CommonAnnotationBeanPostProcessor
|
||||
* @see org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
|
||||
* @see org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor
|
||||
* @see org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor
|
||||
|
|
@ -103,7 +103,6 @@ public class AnnotationConfigUtils {
|
|||
public static final String PERSISTENCE_ANNOTATION_PROCESSOR_BEAN_NAME =
|
||||
"org.springframework.context.annotation.internalPersistenceAnnotationProcessor";
|
||||
|
||||
|
||||
private static final String PERSISTENCE_ANNOTATION_PROCESSOR_CLASS_NAME =
|
||||
"org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor";
|
||||
|
||||
|
|
|
|||
|
|
@ -553,16 +553,15 @@ class ConfigurationClassParser {
|
|||
for (DeferredImportSelectorHolder deferredImport : deferredImports) {
|
||||
Class<? extends Group> group = deferredImport.getImportSelector().getImportGroup();
|
||||
DeferredImportSelectorGrouping grouping = groupings.computeIfAbsent(
|
||||
(group == null ? deferredImport : group),
|
||||
(key) -> new DeferredImportSelectorGrouping(createGroup(group)));
|
||||
(group != null ? group : deferredImport),
|
||||
key -> new DeferredImportSelectorGrouping(createGroup(group)));
|
||||
grouping.add(deferredImport);
|
||||
configurationClasses.put(deferredImport.getConfigurationClass().getMetadata(),
|
||||
deferredImport.getConfigurationClass());
|
||||
}
|
||||
for (DeferredImportSelectorGrouping grouping : groupings.values()) {
|
||||
grouping.getImports().forEach((entry) -> {
|
||||
ConfigurationClass configurationClass = configurationClasses.get(
|
||||
entry.getMetadata());
|
||||
grouping.getImports().forEach(entry -> {
|
||||
ConfigurationClass configurationClass = configurationClasses.get(entry.getMetadata());
|
||||
try {
|
||||
processImports(configurationClass, asSourceClass(configurationClass),
|
||||
asSourceClasses(entry.getImportClassName()), false);
|
||||
|
|
@ -573,15 +572,14 @@ class ConfigurationClassParser {
|
|||
catch (Throwable ex) {
|
||||
throw new BeanDefinitionStoreException(
|
||||
"Failed to process import candidates for configuration class [" +
|
||||
configurationClass.getMetadata().getClassName() + "]", ex);
|
||||
configurationClass.getMetadata().getClassName() + "]", ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private Group createGroup(@Nullable Class<? extends Group> type) {
|
||||
Class<? extends Group> effectiveType = (type != null ? type
|
||||
: DefaultDeferredImportSelectorGroup.class);
|
||||
Class<? extends Group> effectiveType = (type != null ? type : DefaultDeferredImportSelectorGroup.class);
|
||||
Group group = BeanUtils.instantiateClass(effectiveType);
|
||||
ParserStrategyUtils.invokeAwareMethods(group,
|
||||
ConfigurationClassParser.this.environment,
|
||||
|
|
@ -705,7 +703,7 @@ class ConfigurationClassParser {
|
|||
}
|
||||
|
||||
/**
|
||||
* Factory method to obtain {@link SourceClass}s from class names.
|
||||
* Factory method to obtain {@link SourceClass SourceClasss} from class names.
|
||||
*/
|
||||
private Collection<SourceClass> asSourceClasses(String... classNames) throws IOException {
|
||||
List<SourceClass> annotatedClasses = new ArrayList<>(classNames.length);
|
||||
|
|
|
|||
|
|
@ -1252,8 +1252,8 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
|
|||
*/
|
||||
@Nullable
|
||||
protected BeanFactory getInternalParentBeanFactory() {
|
||||
return (getParent() instanceof ConfigurableApplicationContext) ?
|
||||
((ConfigurableApplicationContext) getParent()).getBeanFactory() : getParent();
|
||||
return (getParent() instanceof ConfigurableApplicationContext ?
|
||||
((ConfigurableApplicationContext) getParent()).getBeanFactory() : getParent());
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1295,8 +1295,8 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
|
|||
*/
|
||||
@Nullable
|
||||
protected MessageSource getInternalParentMessageSource() {
|
||||
return (getParent() instanceof AbstractApplicationContext) ?
|
||||
((AbstractApplicationContext) getParent()).messageSource : getParent();
|
||||
return (getParent() instanceof AbstractApplicationContext ?
|
||||
((AbstractApplicationContext) getParent()).messageSource : getParent());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -143,8 +143,9 @@ public abstract class AbstractRefreshableApplicationContext extends AbstractAppl
|
|||
@Override
|
||||
protected void cancelRefresh(BeansException ex) {
|
||||
synchronized (this.beanFactoryMonitor) {
|
||||
if (this.beanFactory != null)
|
||||
if (this.beanFactory != null) {
|
||||
this.beanFactory.setSerializationId(null);
|
||||
}
|
||||
}
|
||||
super.cancelRefresh(ex);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,16 +144,16 @@ public class PeriodicTrigger implements Trigger {
|
|||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof PeriodicTrigger)) {
|
||||
if (!(other instanceof PeriodicTrigger)) {
|
||||
return false;
|
||||
}
|
||||
PeriodicTrigger other = (PeriodicTrigger) obj;
|
||||
return (this.fixedRate == other.fixedRate && this.initialDelay == other.initialDelay &&
|
||||
this.period == other.period);
|
||||
PeriodicTrigger otherTrigger = (PeriodicTrigger) other;
|
||||
return (this.fixedRate == otherTrigger.fixedRate && this.initialDelay == otherTrigger.initialDelay &&
|
||||
this.period == otherTrigger.period);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -38,21 +38,40 @@ public class ScheduledMethodRunnable implements Runnable {
|
|||
private final Method method;
|
||||
|
||||
|
||||
/**
|
||||
* Create a {@code ScheduledMethodRunnable} for the given target instance,
|
||||
* calling the specified method.
|
||||
* @param target the target instance to call the method on
|
||||
* @param method the target method to call
|
||||
*/
|
||||
public ScheduledMethodRunnable(Object target, Method method) {
|
||||
this.target = target;
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@code ScheduledMethodRunnable} for the given target instance,
|
||||
* calling the specified method by name.
|
||||
* @param target the target instance to call the method on
|
||||
* @param methodName the name of the target method
|
||||
* @throws NoSuchMethodException if the specified method does not exist
|
||||
*/
|
||||
public ScheduledMethodRunnable(Object target, String methodName) throws NoSuchMethodException {
|
||||
this.target = target;
|
||||
this.method = target.getClass().getMethod(methodName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the target instance to call the method on.
|
||||
*/
|
||||
public Object getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the target method to call.
|
||||
*/
|
||||
public Method getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,8 +136,8 @@ import org.springframework.util.StringUtils;
|
|||
* @author Mark Fisher
|
||||
* @since 2.0
|
||||
*/
|
||||
public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProcessorAdapter implements
|
||||
BeanClassLoaderAware, BeanFactoryAware, ResourceLoaderAware, DisposableBean, Ordered {
|
||||
public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProcessorAdapter
|
||||
implements BeanClassLoaderAware, BeanFactoryAware, ResourceLoaderAware, DisposableBean, Ordered {
|
||||
|
||||
/**
|
||||
* The {@link org.springframework.core.io.Resource}-style prefix that denotes
|
||||
|
|
@ -275,8 +275,8 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
|
|||
if (ex instanceof BeanCreationException &&
|
||||
((BeanCreationException) ex).getMostSpecificCause() instanceof BeanCurrentlyInCreationException) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Could not determine scripted object type for bean '" + beanName + "': "
|
||||
+ ex.getMessage());
|
||||
logger.trace("Could not determine scripted object type for bean '" + beanName + "': " +
|
||||
ex.getMessage());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -715,8 +715,8 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
|
|||
* @see #doBind(org.springframework.beans.MutablePropertyValues)
|
||||
*/
|
||||
public void bind(PropertyValues pvs) {
|
||||
MutablePropertyValues mpvs = (pvs instanceof MutablePropertyValues) ?
|
||||
(MutablePropertyValues) pvs : new MutablePropertyValues(pvs);
|
||||
MutablePropertyValues mpvs = (pvs instanceof MutablePropertyValues ?
|
||||
(MutablePropertyValues) pvs : new MutablePropertyValues(pvs));
|
||||
doBind(mpvs);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,14 +93,8 @@ public abstract class AttributeAccessorSupport implements AttributeAccessor, Ser
|
|||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof AttributeAccessorSupport)) {
|
||||
return false;
|
||||
}
|
||||
AttributeAccessorSupport that = (AttributeAccessorSupport) other;
|
||||
return this.attributes.equals(that.attributes);
|
||||
return (this == other || (other instanceof AttributeAccessorSupport &&
|
||||
this.attributes.equals(((AttributeAccessorSupport) other).attributes)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -64,9 +64,9 @@ public abstract class ParameterizedTypeReference<T> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (this == obj || (obj instanceof ParameterizedTypeReference &&
|
||||
this.type.equals(((ParameterizedTypeReference<?>) obj).type)));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof ParameterizedTypeReference &&
|
||||
this.type.equals(((ParameterizedTypeReference<?>) other).type)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -164,12 +164,10 @@ public class ReactiveAdapterRegistry {
|
|||
/**
|
||||
* Return a shared default {@code ReactiveAdapterRegistry} instance, lazily
|
||||
* building it once needed.
|
||||
*
|
||||
* <p><b>NOTE:</b> 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";
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -131,9 +131,9 @@ public abstract class PropertySource<T> {
|
|||
* <p>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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
* <p>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);
|
||||
|
|
|
|||
|
|
@ -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}.
|
||||
*
|
||||
* <p>Inspired by Netty's {@code ByteBuf}. Introduced so that non-Netty runtimes (i.e. Servlet)
|
||||
* do not require Netty on the classpath.
|
||||
* <p>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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -833,12 +833,12 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen
|
|||
|
||||
@Override
|
||||
public boolean contains(@Nullable Object o) {
|
||||
if (o != null && o instanceof Map.Entry<?, ?>) {
|
||||
if (o instanceof Map.Entry<?, ?>) {
|
||||
Map.Entry<?, ?> entry = (java.util.Map.Entry<?, ?>) o;
|
||||
Reference<K, V> reference = ConcurrentReferenceHashMap.this.getReference(entry.getKey(), Restructure.NEVER);
|
||||
Entry<K, V> other = (reference != null ? reference.get() : null);
|
||||
if (other != null) {
|
||||
return ObjectUtils.nullSafeEquals(entry.getValue(), other.getValue());
|
||||
Entry<K, V> otherEntry = (reference != null ? reference.get() : null);
|
||||
if (otherEntry != null) {
|
||||
return ObjectUtils.nullSafeEquals(otherEntry.getValue(), otherEntry.getValue());
|
||||
}
|
||||
}
|
||||
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.
|
||||
|
|
@ -67,9 +67,9 @@ public class BooleanComparator implements Comparator<Boolean>, Serializable {
|
|||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (this == obj ||
|
||||
(obj instanceof BooleanComparator && (this.trueLow == ((BooleanComparator) obj).trueLow)));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof BooleanComparator &&
|
||||
this.trueLow == ((BooleanComparator) other).trueLow));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -186,15 +186,9 @@ public class CompoundComparator<T> implements Comparator<T>, Serializable {
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof CompoundComparator)) {
|
||||
return false;
|
||||
}
|
||||
CompoundComparator<T> other = (CompoundComparator<T>) obj;
|
||||
return this.comparators.equals(other.comparators);
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof CompoundComparator &&
|
||||
this.comparators.equals(((CompoundComparator<T>) other).comparators)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -107,15 +107,15 @@ public class InvertibleComparator<T> implements Comparator<T>, Serializable {
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof InvertibleComparator)) {
|
||||
if (!(other instanceof InvertibleComparator)) {
|
||||
return false;
|
||||
}
|
||||
InvertibleComparator<T> other = (InvertibleComparator<T>) obj;
|
||||
return (this.comparator.equals(other.comparator) && this.ascending == other.ascending);
|
||||
InvertibleComparator<T> otherComp = (InvertibleComparator<T>) other;
|
||||
return (this.comparator.equals(otherComp.comparator) && this.ascending == otherComp.ascending);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -107,15 +107,15 @@ public class NullSafeComparator<T> implements Comparator<T> {
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof NullSafeComparator)) {
|
||||
if (!(other instanceof NullSafeComparator)) {
|
||||
return false;
|
||||
}
|
||||
NullSafeComparator<T> other = (NullSafeComparator<T>) obj;
|
||||
return (this.nonNullComparator.equals(other.nonNullComparator) && this.nullsLow == other.nullsLow);
|
||||
NullSafeComparator<T> otherComp = (NullSafeComparator<T>) other;
|
||||
return (this.nonNullComparator.equals(otherComp.nonNullComparator) && this.nullsLow == otherComp.nullsLow);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -530,24 +530,27 @@ public class CodeFlow implements Opcodes {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns if the descriptor is for a boolean primitive or boolean reference type.
|
||||
* @param descriptor type descriptor
|
||||
* @return {@code true} if the descriptor is for a boolean primitive or boolean reference type
|
||||
* @return {@code true} if the descriptor is boolean compatible
|
||||
*/
|
||||
public static boolean isBooleanCompatible(@Nullable String descriptor) {
|
||||
return (descriptor != null && (descriptor.equals("Z") || descriptor.equals("Ljava/lang/Boolean")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the descriptor is for a primitive type.
|
||||
* @param descriptor type descriptor
|
||||
* @return {@code true} if the descriptor is for a primitive type
|
||||
* @return {@code true} if a primitive type
|
||||
*/
|
||||
public static boolean isPrimitive(@Nullable String descriptor) {
|
||||
return (descriptor != null && descriptor.length() == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the descriptor is for a primitive array (e.g. "[[I").
|
||||
* @param descriptor the descriptor for a possible primitive array
|
||||
* @return {@code true} if the descriptor is for a primitive array (e.g. "[[I")
|
||||
* @return {@code true} if the descriptor a primitive array
|
||||
*/
|
||||
public static boolean isPrimitiveArray(@Nullable String descriptor) {
|
||||
if (descriptor == null) {
|
||||
|
|
@ -662,6 +665,7 @@ public class CodeFlow implements Opcodes {
|
|||
}
|
||||
|
||||
/**
|
||||
* Convert a type descriptor to the single character primitive descriptor.
|
||||
* @param descriptor a descriptor for a type that should have a primitive representation
|
||||
* @return the single character descriptor for a primitive input descriptor
|
||||
*/
|
||||
|
|
@ -903,16 +907,33 @@ public class CodeFlow implements Opcodes {
|
|||
public static void insertArrayStore(MethodVisitor mv, String arrayElementType) {
|
||||
if (arrayElementType.length()==1) {
|
||||
switch (arrayElementType.charAt(0)) {
|
||||
case 'I': mv.visitInsn(IASTORE); break;
|
||||
case 'J': mv.visitInsn(LASTORE); break;
|
||||
case 'F': mv.visitInsn(FASTORE); break;
|
||||
case 'D': mv.visitInsn(DASTORE); break;
|
||||
case 'B': mv.visitInsn(BASTORE); break;
|
||||
case 'C': mv.visitInsn(CASTORE); break;
|
||||
case 'S': mv.visitInsn(SASTORE); break;
|
||||
case 'Z': mv.visitInsn(BASTORE); break;
|
||||
case 'I':
|
||||
mv.visitInsn(IASTORE);
|
||||
break;
|
||||
case 'J':
|
||||
mv.visitInsn(LASTORE);
|
||||
break;
|
||||
case 'F':
|
||||
mv.visitInsn(FASTORE);
|
||||
break;
|
||||
case 'D':
|
||||
mv.visitInsn(DASTORE);
|
||||
break;
|
||||
case 'B':
|
||||
mv.visitInsn(BASTORE);
|
||||
break;
|
||||
case 'C':
|
||||
mv.visitInsn(CASTORE);
|
||||
break;
|
||||
case 'S':
|
||||
mv.visitInsn(SASTORE);
|
||||
break;
|
||||
case 'Z':
|
||||
mv.visitInsn(BASTORE);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unexpected arraytype "+arrayElementType.charAt(0));
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected arraytype " + arrayElementType.charAt(0));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -941,13 +962,15 @@ public class CodeFlow implements Opcodes {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return true if the supplied array type has a core component reference type
|
||||
* Return if the supplied array type has a core component reference type.
|
||||
*/
|
||||
public static boolean isReferenceTypeArray(String arraytype) {
|
||||
int length = arraytype.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
char ch = arraytype.charAt(i);
|
||||
if (ch == '[') continue;
|
||||
if (ch == '[') {
|
||||
continue;
|
||||
}
|
||||
return ch=='L';
|
||||
}
|
||||
return false;
|
||||
|
|
@ -1003,21 +1026,7 @@ public class CodeFlow implements Opcodes {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface FieldAdder {
|
||||
|
||||
void generateField(ClassWriter cw, CodeFlow codeflow);
|
||||
}
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ClinitAdder {
|
||||
|
||||
void generateCode(MethodVisitor mv, CodeFlow codeflow);
|
||||
}
|
||||
|
||||
public static String toBoxedDescriptor(String primitiveDescriptor) {
|
||||
public static final String toBoxedDescriptor(String primitiveDescriptor) {
|
||||
switch (primitiveDescriptor.charAt(0)) {
|
||||
case 'I': return "Ljava/lang/Integer";
|
||||
case 'J': return "Ljava/lang/Long";
|
||||
|
|
@ -1029,7 +1038,27 @@ public class CodeFlow implements Opcodes {
|
|||
case 'Z': return "Ljava/lang/Boolean";
|
||||
default:
|
||||
throw new IllegalArgumentException("Unexpected non primitive descriptor "+primitiveDescriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Interface used to generate fields.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface FieldAdder {
|
||||
|
||||
void generateField(ClassWriter cw, CodeFlow codeflow);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Interface used to generate {@code clinit} static initializer blocks.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ClinitAdder {
|
||||
|
||||
void generateCode(MethodVisitor mv, CodeFlow codeflow);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -205,10 +205,10 @@ public class OpPlus extends Operator {
|
|||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void generateCode(MethodVisitor mv, CodeFlow cf) {
|
||||
if (this.exitTypeDescriptor == "Ljava/lang/String") {
|
||||
if ("Ljava/lang/String".equals(this.exitTypeDescriptor)) {
|
||||
mv.visitTypeInsn(NEW, "java/lang/StringBuilder");
|
||||
mv.visitInsn(DUP);
|
||||
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "()V", false);
|
||||
|
|
@ -236,12 +236,12 @@ public class OpPlus extends Operator {
|
|||
case 'J':
|
||||
mv.visitInsn(LADD);
|
||||
break;
|
||||
case 'F':
|
||||
case 'F':
|
||||
mv.visitInsn(FADD);
|
||||
break;
|
||||
case 'D':
|
||||
mv.visitInsn(DADD);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException(
|
||||
"Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 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.
|
||||
|
|
@ -38,7 +38,7 @@ public class JdbcUpdateAffectedIncorrectNumberOfRowsException extends IncorrectU
|
|||
|
||||
/**
|
||||
* Constructor for JdbcUpdateAffectedIncorrectNumberOfRowsException.
|
||||
* @param sql SQL we were tring to execute
|
||||
* @param sql the SQL we were trying to execute
|
||||
* @param expected the expected number of rows affected
|
||||
* @param actual the actual number of rows affected
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -117,9 +117,9 @@ public class MessagingMessageConverter implements MessageConverter, Initializing
|
|||
public Object fromMessage(javax.jms.Message message) throws JMSException, MessageConversionException {
|
||||
Map<String, Object> mappedHeaders = extractHeaders(message);
|
||||
Object convertedObject = extractPayload(message);
|
||||
MessageBuilder<Object> builder = (convertedObject instanceof org.springframework.messaging.Message) ?
|
||||
MessageBuilder<Object> builder = (convertedObject instanceof org.springframework.messaging.Message ?
|
||||
MessageBuilder.fromMessage((org.springframework.messaging.Message<Object>) convertedObject) :
|
||||
MessageBuilder.withPayload(convertedObject);
|
||||
MessageBuilder.withPayload(convertedObject));
|
||||
return builder.copyHeadersIfAbsent(mappedHeaders).build();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,33 +30,17 @@ import org.springframework.lang.Nullable;
|
|||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
*/
|
||||
public abstract class AbstractMessageCondition<T extends AbstractMessageCondition<T>>
|
||||
implements MessageCondition<T> {
|
||||
|
||||
|
||||
/**
|
||||
* Return the collection of objects the message condition is composed of
|
||||
* (e.g. destination patterns), never {@code null}.
|
||||
*/
|
||||
protected abstract Collection<?> getContent();
|
||||
|
||||
/**
|
||||
* The notation to use when printing discrete items of content.
|
||||
* For example " || " for URL patterns or " && " for param expressions.
|
||||
*/
|
||||
protected abstract String getToStringInfix();
|
||||
|
||||
public abstract class AbstractMessageCondition<T extends AbstractMessageCondition<T>> implements MessageCondition<T> {
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj != null && getClass() == obj.getClass()) {
|
||||
AbstractMessageCondition<?> other = (AbstractMessageCondition<?>) obj;
|
||||
return getContent().equals(other.getContent());
|
||||
if (other == null || getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
return getContent().equals(((AbstractMessageCondition<?>) other).getContent());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -78,4 +62,17 @@ public abstract class AbstractMessageCondition<T extends AbstractMessageConditio
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the collection of objects the message condition is composed of
|
||||
* (e.g. destination patterns), never {@code null}.
|
||||
*/
|
||||
protected abstract Collection<?> getContent();
|
||||
|
||||
/**
|
||||
* The notation to use when printing discrete items of content.
|
||||
* For example " || " for URL patterns or " && " for param expressions.
|
||||
*/
|
||||
protected abstract String getToStringInfix();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,16 +93,16 @@ public class SimpMessageMappingInfo implements MessageCondition<SimpMessageMappi
|
|||
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj != null && obj instanceof SimpMessageMappingInfo) {
|
||||
SimpMessageMappingInfo other = (SimpMessageMappingInfo) obj;
|
||||
return (this.destinationConditions.equals(other.destinationConditions) &&
|
||||
this.messageTypeMessageCondition.equals(other.messageTypeMessageCondition));
|
||||
if (!(other instanceof SimpMessageMappingInfo)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
SimpMessageMappingInfo otherInfo = (SimpMessageMappingInfo) other;
|
||||
return (this.destinationConditions.equals(otherInfo.destinationConditions) &&
|
||||
this.messageTypeMessageCondition.equals(otherInfo.messageTypeMessageCondition));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -44,7 +44,6 @@ import org.springframework.core.io.support.ResourcePatternUtils;
|
|||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.core.type.filter.TypeFilter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* {@link FactoryBean} that creates a Hibernate
|
||||
|
|
@ -351,8 +350,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
|
|||
* then block until Hibernate's bootstrapping completed, if not ready by then.
|
||||
* For maximum benefit, make sure to avoid early {@code SessionFactory} calls
|
||||
* in init methods of related beans, even for metadata introspection purposes.
|
||||
* @see LocalSessionFactoryBuilder#buildSessionFactory(AsyncTaskExecutor)
|
||||
* @since 4.3
|
||||
* @see LocalSessionFactoryBuilder#buildSessionFactory(AsyncTaskExecutor)
|
||||
*/
|
||||
public void setBootstrapExecutor(AsyncTaskExecutor bootstrapExecutor) {
|
||||
this.bootstrapExecutor = bootstrapExecutor;
|
||||
|
|
@ -365,7 +364,6 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
|
|||
* @since 4.3
|
||||
*/
|
||||
public void setMetadataSources(MetadataSources metadataSources) {
|
||||
Assert.notNull(metadataSources, "MetadataSources must not be null");
|
||||
this.metadataSourcesAccessed = true;
|
||||
this.metadataSources = metadataSources;
|
||||
}
|
||||
|
|
@ -526,7 +524,7 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
|
|||
* <p>The default implementation invokes LocalSessionFactoryBuilder's buildSessionFactory.
|
||||
* A custom implementation could prepare the instance in a specific way (e.g. applying
|
||||
* a custom ServiceRegistry) or use a custom SessionFactoryImpl subclass.
|
||||
* @param sfb LocalSessionFactoryBuilder prepared by this LocalSessionFactoryBean
|
||||
* @param sfb a LocalSessionFactoryBuilder prepared by this LocalSessionFactoryBean
|
||||
* @return the SessionFactory instance
|
||||
* @see LocalSessionFactoryBuilder#buildSessionFactory
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -136,7 +136,9 @@ public class LocalSessionFactoryBuilder extends Configuration {
|
|||
* @param metadataSources the Hibernate MetadataSources service to use (e.g. reusing an existing one)
|
||||
* @since 4.3
|
||||
*/
|
||||
public LocalSessionFactoryBuilder(@Nullable DataSource dataSource, ResourceLoader resourceLoader, MetadataSources metadataSources) {
|
||||
public LocalSessionFactoryBuilder(
|
||||
@Nullable DataSource dataSource, ResourceLoader resourceLoader, MetadataSources metadataSources) {
|
||||
|
||||
super(metadataSources);
|
||||
|
||||
getProperties().put(AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName());
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -44,9 +44,9 @@ public class SpringFlushSynchronization extends TransactionSynchronizationAdapte
|
|||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj instanceof SpringFlushSynchronization &&
|
||||
this.session == ((SpringFlushSynchronization) obj).session);
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof SpringFlushSynchronization &&
|
||||
this.session == ((SpringFlushSynchronization) other).session));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -25,7 +25,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
|
|
@ -96,8 +95,7 @@ public class SpringClassRule implements TestRule {
|
|||
/**
|
||||
* Cache of {@code TestContextManagers} keyed by test class.
|
||||
*/
|
||||
private static final Map<Class<?>, TestContextManager> testContextManagerCache =
|
||||
new ConcurrentHashMap<>(64);
|
||||
private static final Map<Class<?>, TestContextManager> testContextManagerCache = new ConcurrentHashMap<>(64);
|
||||
|
||||
static {
|
||||
Assert.state(ClassUtils.isPresent("org.junit.internal.Throwables", SpringClassRule.class.getClassLoader()),
|
||||
|
|
@ -186,12 +184,12 @@ public class SpringClassRule implements TestRule {
|
|||
private static void validateSpringMethodRuleConfiguration(Class<?> testClass) {
|
||||
Field ruleField = findSpringMethodRuleField(testClass).orElseThrow(() ->
|
||||
new IllegalStateException(String.format(
|
||||
"Failed to find 'public SpringMethodRule' field in test class [%s]. " +
|
||||
"Consult the javadoc for SpringClassRule for details.", testClass.getName())));
|
||||
"Failed to find 'public SpringMethodRule' field in test class [%s]. " +
|
||||
"Consult the javadoc for SpringClassRule for details.", testClass.getName())));
|
||||
|
||||
Assert.state(ruleField.isAnnotationPresent(Rule.class), () -> String.format(
|
||||
"SpringMethodRule field [%s] must be annotated with JUnit's @Rule annotation. " +
|
||||
"Consult the javadoc for SpringClassRule for details.", ruleField));
|
||||
"SpringMethodRule field [%s] must be annotated with JUnit's @Rule annotation. " +
|
||||
"Consult the javadoc for SpringClassRule for details.", ruleField));
|
||||
}
|
||||
|
||||
private static Optional<Field> findSpringMethodRuleField(Class<?> testClass) {
|
||||
|
|
@ -207,7 +205,7 @@ public class SpringClassRule implements TestRule {
|
|||
* @param testClass the test class to be managed; never {@code null}
|
||||
*/
|
||||
static TestContextManager getTestContextManager(Class<?> testClass) {
|
||||
Assert.notNull(testClass, "testClass must not be null");
|
||||
Assert.notNull(testClass, "Test Class must not be null");
|
||||
return testContextManagerCache.computeIfAbsent(testClass, TestContextManager::new);
|
||||
}
|
||||
|
||||
|
|
@ -218,7 +216,6 @@ public class SpringClassRule implements TestRule {
|
|||
|
||||
private final Class<?> testClass;
|
||||
|
||||
|
||||
TestContextManagerCacheEvictor(Statement next, Class<?> testClass) {
|
||||
this.next = next;
|
||||
this.testClass = testClass;
|
||||
|
|
@ -227,10 +224,10 @@ public class SpringClassRule implements TestRule {
|
|||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
try {
|
||||
next.evaluate();
|
||||
this.next.evaluate();
|
||||
}
|
||||
finally {
|
||||
testContextManagerCache.remove(testClass);
|
||||
testContextManagerCache.remove(this.testClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -182,8 +182,8 @@ public class SpringMethodRule implements MethodRule {
|
|||
* Wrap the supplied {@link Statement} with a {@code RunPrepareTestInstanceCallbacks} statement.
|
||||
* @see RunPrepareTestInstanceCallbacks
|
||||
*/
|
||||
private Statement withTestInstancePreparation(Statement next, Object testInstance,
|
||||
TestContextManager testContextManager) {
|
||||
private Statement withTestInstancePreparation(
|
||||
Statement next, Object testInstance, TestContextManager testContextManager) {
|
||||
|
||||
return new RunPrepareTestInstanceCallbacks(next, testInstance, testContextManager);
|
||||
}
|
||||
|
|
@ -225,8 +225,8 @@ public class SpringMethodRule implements MethodRule {
|
|||
private static SpringClassRule validateSpringClassRuleConfiguration(Class<?> testClass) {
|
||||
Field ruleField = findSpringClassRuleField(testClass).orElseThrow(() ->
|
||||
new IllegalStateException(String.format(
|
||||
"Failed to find 'public static final SpringClassRule' field in test class [%s]. " +
|
||||
"Consult the javadoc for SpringClassRule for details.", testClass.getName())));
|
||||
"Failed to find 'public static final SpringClassRule' field in test class [%s]. " +
|
||||
"Consult the javadoc for SpringClassRule for details.", testClass.getName())));
|
||||
|
||||
Assert.state(ruleField.isAnnotationPresent(ClassRule.class), () -> String.format(
|
||||
"SpringClassRule field [%s] must be annotated with JUnit's @ClassRule annotation. " +
|
||||
|
|
|
|||
|
|
@ -243,10 +243,10 @@ public class SpringContextResourceAdapter implements ResourceAdapter {
|
|||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj instanceof SpringContextResourceAdapter &&
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof SpringContextResourceAdapter &&
|
||||
ObjectUtils.nullSafeEquals(getContextConfigLocation(),
|
||||
((SpringContextResourceAdapter) obj).getContextConfigLocation()));
|
||||
((SpringContextResourceAdapter) other).getContextConfigLocation())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ public abstract class DelegatingTransactionDefinition implements TransactionDefi
|
|||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return this.targetDefinition.equals(obj);
|
||||
public boolean equals(Object other) {
|
||||
return this.targetDefinition.equals(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -101,9 +101,9 @@ public final class MultipartBodyBuilder {
|
|||
HttpHeaders partHeaders = new HttpHeaders();
|
||||
|
||||
if (part instanceof HttpEntity) {
|
||||
HttpEntity<?> other = (HttpEntity<?>) part;
|
||||
partBody = other.getBody();
|
||||
partHeaders.addAll(other.getHeaders());
|
||||
HttpEntity<?> httpEntity = (HttpEntity<?>) part;
|
||||
partBody = httpEntity.getBody();
|
||||
partHeaders.addAll(httpEntity.getHeaders());
|
||||
}
|
||||
else {
|
||||
partBody = part;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package org.springframework.http.codec;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -48,8 +49,6 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
|
|||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
|
||||
/**
|
||||
* {@code HttpMessageWriter} that can write a {@link Resource}.
|
||||
*
|
||||
|
|
@ -232,7 +231,7 @@ public class ResourceHttpMessageWriter implements HttpMessageWriter<Resource> {
|
|||
.orElseGet(() -> {
|
||||
Publisher<? extends ResourceRegion> input = Mono.just(region);
|
||||
MediaType mediaType = message.getHeaders().getContentType();
|
||||
return encodeAndWriteRegions(input, mediaType, message, emptyMap());
|
||||
return encodeAndWriteRegions(input, mediaType, message, Collections.emptyMap());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,19 +90,14 @@ public class SynchronossPartHttpMessageReader implements HttpMessageReader<Part>
|
|||
|
||||
|
||||
@Override
|
||||
public Flux<Part> read(ResolvableType elementType, ReactiveHttpInputMessage message,
|
||||
Map<String, Object> hints) {
|
||||
|
||||
public Flux<Part> read(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) {
|
||||
return Flux.create(new SynchronossPartGenerator(message, this.bufferFactory, this.streamStorageFactory));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Mono<Part> readMono(ResolvableType elementType, ReactiveHttpInputMessage message,
|
||||
Map<String, Object> hints) {
|
||||
|
||||
return Mono.error(new UnsupportedOperationException(
|
||||
"Can't read a multipart request body into a single Part."));
|
||||
public Mono<Part> readMono(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) {
|
||||
return Mono.error(new UnsupportedOperationException("Cannot read multipart request body into single Part"));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -115,18 +110,17 @@ public class SynchronossPartHttpMessageReader implements HttpMessageReader<Part>
|
|||
private final ReactiveHttpInputMessage inputMessage;
|
||||
|
||||
private final DataBufferFactory bufferFactory;
|
||||
|
||||
private final PartBodyStreamStorageFactory streamStorageFactory;
|
||||
|
||||
private final PartBodyStreamStorageFactory streamStorageFactory;
|
||||
|
||||
SynchronossPartGenerator(ReactiveHttpInputMessage inputMessage, DataBufferFactory bufferFactory,
|
||||
PartBodyStreamStorageFactory streamStorageFactory) {
|
||||
|
||||
this.inputMessage = inputMessage;
|
||||
this.bufferFactory = bufferFactory;
|
||||
this.streamStorageFactory = streamStorageFactory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void accept(FluxSink<Part> emitter) {
|
||||
HttpHeaders headers = this.inputMessage.getHeaders();
|
||||
|
|
@ -140,7 +134,7 @@ public class SynchronossPartHttpMessageReader implements HttpMessageReader<Part>
|
|||
NioMultipartParserListener listener = new FluxSinkAdapterListener(emitter, this.bufferFactory, context);
|
||||
NioMultipartParser parser = Multipart
|
||||
.multipart(context)
|
||||
.usePartBodyStreamStorageFactory(streamStorageFactory)
|
||||
.usePartBodyStreamStorageFactory(this.streamStorageFactory)
|
||||
.forNIO(listener);
|
||||
|
||||
this.inputMessage.getBody().subscribe(buffer -> {
|
||||
|
|
@ -189,14 +183,12 @@ public class SynchronossPartHttpMessageReader implements HttpMessageReader<Part>
|
|||
|
||||
private final AtomicInteger terminated = new AtomicInteger(0);
|
||||
|
||||
|
||||
FluxSinkAdapterListener(FluxSink<Part> sink, DataBufferFactory factory, MultipartContext context) {
|
||||
this.sink = sink;
|
||||
this.bufferFactory = factory;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPartFinished(StreamStorage storage, Map<String, List<String>> headers) {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
|
|
@ -250,16 +242,14 @@ public class SynchronossPartHttpMessageReader implements HttpMessageReader<Part>
|
|||
|
||||
private final DataBufferFactory bufferFactory;
|
||||
|
||||
|
||||
AbstractSynchronossPart(HttpHeaders headers, DataBufferFactory bufferFactory) {
|
||||
Assert.notNull(headers, "HttpHeaders is required");
|
||||
Assert.notNull(bufferFactory, "'bufferFactory' is required");
|
||||
Assert.notNull(bufferFactory, "DataBufferFactory is required");
|
||||
this.name = MultipartUtils.getFieldName(headers);
|
||||
this.headers = headers;
|
||||
this.bufferFactory = bufferFactory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return this.name;
|
||||
|
|
@ -280,14 +270,12 @@ public class SynchronossPartHttpMessageReader implements HttpMessageReader<Part>
|
|||
|
||||
private final StreamStorage storage;
|
||||
|
||||
|
||||
SynchronossPart(HttpHeaders headers, StreamStorage storage, DataBufferFactory factory) {
|
||||
super(headers, factory);
|
||||
Assert.notNull(storage, "'storage' is required");
|
||||
Assert.notNull(storage, "StreamStorage is required");
|
||||
this.storage = storage;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Flux<DataBuffer> content() {
|
||||
return DataBufferUtils.readInputStream(getStorage()::getInputStream, getBufferFactory(), 4096);
|
||||
|
|
@ -301,21 +289,16 @@ public class SynchronossPartHttpMessageReader implements HttpMessageReader<Part>
|
|||
|
||||
private static class SynchronossFilePart extends SynchronossPart implements FilePart {
|
||||
|
||||
private static final OpenOption[] FILE_CHANNEL_OPTIONS = {
|
||||
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE };
|
||||
|
||||
private static final OpenOption[] FILE_CHANNEL_OPTIONS =
|
||||
{StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE};
|
||||
|
||||
private final String filename;
|
||||
|
||||
|
||||
SynchronossFilePart(HttpHeaders headers, String filename, StreamStorage storage,
|
||||
DataBufferFactory factory) {
|
||||
|
||||
SynchronossFilePart(HttpHeaders headers, String filename, StreamStorage storage, DataBufferFactory factory) {
|
||||
super(headers, storage, factory);
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String filename() {
|
||||
return this.filename;
|
||||
|
|
@ -366,13 +349,11 @@ public class SynchronossPartHttpMessageReader implements HttpMessageReader<Part>
|
|||
|
||||
private final String content;
|
||||
|
||||
|
||||
SynchronossFormFieldPart(HttpHeaders headers, DataBufferFactory bufferFactory, String content) {
|
||||
super(headers, bufferFactory);
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String value() {
|
||||
return this.content;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -132,10 +132,10 @@ class DefaultRequestPath implements RequestPath {
|
|||
if (other == null || getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
DefaultRequestPath that = (DefaultRequestPath) other;
|
||||
return (this.fullPath.equals(that.fullPath) &&
|
||||
this.contextPath.equals(that.contextPath) &&
|
||||
this.pathWithinApplication.equals(that.pathWithinApplication));
|
||||
DefaultRequestPath otherPath= (DefaultRequestPath) other;
|
||||
return (this.fullPath.equals(otherPath.fullPath) &&
|
||||
this.contextPath.equals(otherPath.contextPath) &&
|
||||
this.pathWithinApplication.equals(otherPath.pathWithinApplication));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -63,6 +63,8 @@ import org.springframework.stereotype.Component;
|
|||
* @author Brian Clozel
|
||||
* @author Sam Brannen
|
||||
* @since 3.2
|
||||
* @see org.springframework.stereotype.Controller
|
||||
* @see RestControllerAdvice
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -41,6 +41,8 @@ import org.springframework.core.annotation.AliasFor;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.3
|
||||
* @see RestController
|
||||
* @see ControllerAdvice
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
|
|
|||
|
|
@ -237,15 +237,15 @@ public class ServletContextResource extends AbstractFileResolvingResource implem
|
|||
* This implementation compares the underlying ServletContext resource locations.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof ServletContextResource) {
|
||||
ServletContextResource otherRes = (ServletContextResource) obj;
|
||||
return (this.servletContext.equals(otherRes.servletContext) && this.path.equals(otherRes.path));
|
||||
if (!(other instanceof ServletContextResource)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
ServletContextResource otherRes = (ServletContextResource) other;
|
||||
return (this.servletContext.equals(otherRes.servletContext) && this.path.equals(otherRes.path));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -43,13 +43,12 @@ import org.springframework.web.multipart.MultipartResolver;
|
|||
*
|
||||
* <pre class="code">
|
||||
* public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
|
||||
* // ...
|
||||
* @Override
|
||||
* protected void customizeRegistration(ServletRegistration.Dynamic registration) {
|
||||
*
|
||||
* // Optionally also set maxFileSize, maxRequestSize, fileSizeThreshold
|
||||
* registration.setMultipartConfig(new MultipartConfigElement("/tmp"));
|
||||
* }
|
||||
* // ...
|
||||
* @Override
|
||||
* protected void customizeRegistration(ServletRegistration.Dynamic registration) {
|
||||
* // Optionally also set maxFileSize, maxRequestSize, fileSizeThreshold
|
||||
* registration.setMultipartConfig(new MultipartConfigElement("/tmp"));
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
|
|
@ -84,8 +83,7 @@ public class StandardServletMultipartResolver implements MultipartResolver {
|
|||
if (!"post".equalsIgnoreCase(request.getMethod())) {
|
||||
return false;
|
||||
}
|
||||
String contentType = request.getContentType();
|
||||
return StringUtils.startsWithIgnoreCase(contentType, "multipart/");
|
||||
return StringUtils.startsWithIgnoreCase(request.getContentType(), "multipart/");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -54,6 +54,51 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||
private static final String PATH_DELIMITER_STRING = "/";
|
||||
|
||||
|
||||
/**
|
||||
* Represents an empty path.
|
||||
*/
|
||||
static final PathComponent NULL_PATH_COMPONENT = new PathComponent() {
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPathSegments() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathComponent encode(Charset charset) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verify() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathComponent expand(UriTemplateVariables uriVariables) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyToUriComponentsBuilder(UriComponentsBuilder builder) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return (this == other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getClass().hashCode();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@Nullable
|
||||
private final String userInfo;
|
||||
|
||||
|
|
@ -462,21 +507,21 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof HierarchicalUriComponents)) {
|
||||
if (!(other instanceof HierarchicalUriComponents)) {
|
||||
return false;
|
||||
}
|
||||
HierarchicalUriComponents other = (HierarchicalUriComponents) obj;
|
||||
return ObjectUtils.nullSafeEquals(getScheme(), other.getScheme()) &&
|
||||
ObjectUtils.nullSafeEquals(getUserInfo(), other.getUserInfo()) &&
|
||||
ObjectUtils.nullSafeEquals(getHost(), other.getHost()) &&
|
||||
getPort() == other.getPort() &&
|
||||
this.path.equals(other.path) &&
|
||||
this.queryParams.equals(other.queryParams) &&
|
||||
ObjectUtils.nullSafeEquals(getFragment(), other.getFragment());
|
||||
HierarchicalUriComponents otherComp = (HierarchicalUriComponents) other;
|
||||
return (ObjectUtils.nullSafeEquals(getScheme(), otherComp.getScheme()) &&
|
||||
ObjectUtils.nullSafeEquals(getUserInfo(), otherComp.getUserInfo()) &&
|
||||
ObjectUtils.nullSafeEquals(getHost(), otherComp.getHost()) &&
|
||||
getPort() == otherComp.getPort() &&
|
||||
this.path.equals(otherComp.path) &&
|
||||
this.queryParams.equals(otherComp.queryParams) &&
|
||||
ObjectUtils.nullSafeEquals(getFragment(), otherComp.getFragment()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -708,9 +753,9 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (this == obj || (obj instanceof FullPathComponent &&
|
||||
getPath().equals(((FullPathComponent) obj).getPath())));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof FullPathComponent &&
|
||||
getPath().equals(((FullPathComponent) other).getPath())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -786,9 +831,9 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (this == obj || (obj instanceof PathSegmentComponent &&
|
||||
getPathSegments().equals(((PathSegmentComponent) obj).getPathSegments())));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof PathSegmentComponent &&
|
||||
getPathSegments().equals(((PathSegmentComponent) other).getPathSegments())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -862,43 +907,6 @@ final class HierarchicalUriComponents extends UriComponents {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents an empty path.
|
||||
*/
|
||||
static final PathComponent NULL_PATH_COMPONENT = new PathComponent() {
|
||||
@Override
|
||||
public String getPath() {
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
public List<String> getPathSegments() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@Override
|
||||
public PathComponent encode(Charset charset) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public void verify() {
|
||||
}
|
||||
@Override
|
||||
public PathComponent expand(UriTemplateVariables uriVariables) {
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public void copyToUriComponentsBuilder(UriComponentsBuilder builder) {
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (this == obj);
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getClass().hashCode();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private static class QueryUriTemplateVariables implements UriTemplateVariables {
|
||||
|
||||
private final UriTemplateVariables delegate;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -157,19 +157,17 @@ final class OpaqueUriComponents extends UriComponents {
|
|||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof OpaqueUriComponents)) {
|
||||
if (!(other instanceof OpaqueUriComponents)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OpaqueUriComponents other = (OpaqueUriComponents) obj;
|
||||
return ObjectUtils.nullSafeEquals(getScheme(), other.getScheme()) &&
|
||||
ObjectUtils.nullSafeEquals(this.ssp, other.ssp) &&
|
||||
ObjectUtils.nullSafeEquals(getFragment(), other.getFragment());
|
||||
|
||||
OpaqueUriComponents otherComp = (OpaqueUriComponents) other;
|
||||
return (ObjectUtils.nullSafeEquals(getScheme(), otherComp.getScheme()) &&
|
||||
ObjectUtils.nullSafeEquals(this.ssp, otherComp.ssp) &&
|
||||
ObjectUtils.nullSafeEquals(getFragment(), otherComp.getFragment()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -209,17 +209,17 @@ public class ResolvableMethod {
|
|||
}
|
||||
|
||||
private String formatMethod() {
|
||||
return this.method().getName() +
|
||||
return (this.method().getName() +
|
||||
Arrays.stream(this.method.getParameters())
|
||||
.map(this::formatParameter)
|
||||
.collect(joining(",\n\t", "(\n\t", "\n)"));
|
||||
.collect(joining(",\n\t", "(\n\t", "\n)")));
|
||||
}
|
||||
|
||||
private String formatParameter(Parameter param) {
|
||||
Annotation[] annot = param.getAnnotations();
|
||||
return annot.length > 0 ?
|
||||
Arrays.stream(annot).map(this::formatAnnotation).collect(joining(",", "[", "]")) + " " + param :
|
||||
param.toString();
|
||||
Annotation[] anns = param.getAnnotations();
|
||||
return (anns.length > 0 ?
|
||||
Arrays.stream(anns).map(this::formatAnnotation).collect(joining(",", "[", "]")) + " " + param :
|
||||
param.toString());
|
||||
}
|
||||
|
||||
private String formatAnnotation(Annotation annotation) {
|
||||
|
|
@ -536,9 +536,9 @@ public class ResolvableMethod {
|
|||
@SafeVarargs
|
||||
public final ArgResolver annotNotPresent(Class<? extends Annotation>... annotationTypes) {
|
||||
this.filters.add(param ->
|
||||
(annotationTypes.length != 0) ?
|
||||
(annotationTypes.length > 0 ?
|
||||
Arrays.stream(annotationTypes).noneMatch(param::hasParameterAnnotation) :
|
||||
param.getParameterAnnotations().length == 0);
|
||||
param.getParameterAnnotations().length == 0));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.reactive.accept;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -36,7 +37,7 @@ public class HeaderContentTypeResolver implements RequestedContentTypeResolver {
|
|||
try {
|
||||
List<MediaType> mediaTypes = exchange.getRequest().getHeaders().getAccept();
|
||||
MediaType.sortBySpecificityAndQuality(mediaTypes);
|
||||
return !CollectionUtils.isEmpty(mediaTypes) ? mediaTypes : MEDIA_TYPE_ALL_LIST;
|
||||
return (!CollectionUtils.isEmpty(mediaTypes) ? mediaTypes : MEDIA_TYPE_ALL_LIST);
|
||||
}
|
||||
catch (InvalidMediaTypeException ex) {
|
||||
String value = exchange.getRequest().getHeaders().getFirst("Accept");
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -87,11 +87,9 @@ public class RequestedContentTypeResolverBuilder {
|
|||
* of resolvers configured through this builder.
|
||||
*/
|
||||
public RequestedContentTypeResolver build() {
|
||||
|
||||
List<RequestedContentTypeResolver> resolvers =
|
||||
this.candidates.isEmpty() ?
|
||||
Collections.singletonList(new HeaderContentTypeResolver()) :
|
||||
this.candidates.stream().map(Supplier::get).collect(Collectors.toList());
|
||||
List<RequestedContentTypeResolver> resolvers = (!this.candidates.isEmpty() ?
|
||||
this.candidates.stream().map(Supplier::get).collect(Collectors.toList()) :
|
||||
Collections.singletonList(new HeaderContentTypeResolver()));
|
||||
|
||||
return exchange -> {
|
||||
for (RequestedContentTypeResolver resolver : resolvers) {
|
||||
|
|
|
|||
|
|
@ -163,7 +163,6 @@ class DefaultWebClient implements WebClient {
|
|||
|
||||
private final Map<String, Object> attributes = new LinkedHashMap<>(4);
|
||||
|
||||
|
||||
DefaultRequestBodyUriSpec(HttpMethod httpMethod) {
|
||||
this.httpMethod = httpMethod;
|
||||
}
|
||||
|
|
@ -318,7 +317,7 @@ class DefaultWebClient implements WebClient {
|
|||
}
|
||||
|
||||
private ClientRequest.Builder initRequestBuilder() {
|
||||
URI uri = this.uri != null ? this.uri : uriBuilderFactory.expand("");
|
||||
URI uri = (this.uri != null ? this.uri : uriBuilderFactory.expand(""));
|
||||
return ClientRequest.create(this.httpMethod, uri)
|
||||
.headers(headers -> headers.addAll(initHeaders()))
|
||||
.cookies(cookies -> cookies.addAll(initCookies()))
|
||||
|
|
|
|||
|
|
@ -228,9 +228,8 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
|
|||
if (this.uriBuilderFactory != null) {
|
||||
return this.uriBuilderFactory;
|
||||
}
|
||||
DefaultUriBuilderFactory factory = this.baseUrl != null ?
|
||||
new DefaultUriBuilderFactory(this.baseUrl) : new DefaultUriBuilderFactory();
|
||||
|
||||
DefaultUriBuilderFactory factory = (this.baseUrl != null ?
|
||||
new DefaultUriBuilderFactory(this.baseUrl) : new DefaultUriBuilderFactory());
|
||||
factory.setDefaultUriVariables(this.defaultUriVariables);
|
||||
return factory;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,10 +92,8 @@ public abstract class ExchangeFilterFunctions {
|
|||
}
|
||||
|
||||
private static void checkIllegalCharacters(String username, String password) {
|
||||
|
||||
// Basic authentication only supports ISO 8859-1, see
|
||||
// https://stackoverflow.com/questions/702629/utf-8-characters-mangled-in-http-basic-auth-username#703341
|
||||
|
||||
CharsetEncoder encoder = StandardCharsets.ISO_8859_1.newEncoder();
|
||||
if (!encoder.canEncode(username) || !encoder.canEncode(password)) {
|
||||
throw new IllegalArgumentException(
|
||||
|
|
@ -113,7 +111,6 @@ public abstract class ExchangeFilterFunctions {
|
|||
}).build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a filter that generates an error signal when the given
|
||||
* {@link HttpStatus} predicate matches.
|
||||
|
|
@ -128,10 +125,8 @@ public abstract class ExchangeFilterFunctions {
|
|||
Assert.notNull(exceptionFunction, "Function must not be null");
|
||||
|
||||
return ExchangeFilterFunction.ofResponseProcessor(
|
||||
response -> statusPredicate.test(response.statusCode()) ?
|
||||
Mono.error(exceptionFunction.apply(response)) :
|
||||
Mono.just(response)
|
||||
);
|
||||
response -> (statusPredicate.test(response.statusCode()) ?
|
||||
Mono.error(exceptionFunction.apply(response)) : Mono.just(response)));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -146,7 +141,6 @@ public abstract class ExchangeFilterFunctions {
|
|||
|
||||
private final String password;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new {@code Credentials} instance with the given username and password.
|
||||
* @param username the username
|
||||
|
|
@ -159,7 +153,6 @@ public abstract class ExchangeFilterFunctions {
|
|||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a {@literal Consumer} that stores the given user and password
|
||||
* as a request attribute of type {@code Credentials} that is in turn
|
||||
|
|
@ -174,21 +167,19 @@ public abstract class ExchangeFilterFunctions {
|
|||
public static Consumer<Map<String, Object>> basicAuthenticationCredentials(String user, String password) {
|
||||
Credentials credentials = new Credentials(user, password);
|
||||
checkIllegalCharacters(user, password);
|
||||
return map -> map.put(BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE, credentials);
|
||||
return (map -> map.put(BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE, credentials));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof Credentials) {
|
||||
Credentials other = (Credentials) o;
|
||||
return this.username.equals(other.username) &&
|
||||
this.password.equals(other.password);
|
||||
if (!(other instanceof Credentials)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Credentials otherCred = (Credentials) other;
|
||||
return (this.username.equals(otherCred.username) && this.password.equals(otherCred.password));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -38,14 +38,14 @@ public abstract class AbstractPrefixVersionStrategy implements VersionStrategy {
|
|||
|
||||
|
||||
protected AbstractPrefixVersionStrategy(String version) {
|
||||
Assert.hasText(version, "'version' must not be empty");
|
||||
Assert.hasText(version, "Version must not be empty");
|
||||
this.prefix = version;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String extractVersion(String requestPath) {
|
||||
return requestPath.startsWith(this.prefix) ? this.prefix : null;
|
||||
return (requestPath.startsWith(this.prefix) ? this.prefix : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import org.springframework.core.io.Resource;
|
|||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
|
@ -283,19 +282,19 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
|||
|
||||
@Override
|
||||
public int compareTo(ContentChunkInfo other) {
|
||||
return (this.start < other.start ? -1 : (this.start == other.start ? 0 : 1));
|
||||
return Integer.compare(this.start, other.start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj != null && obj instanceof ContentChunkInfo) {
|
||||
ContentChunkInfo other = (ContentChunkInfo) obj;
|
||||
return (this.start == other.start && this.end == other.end);
|
||||
if (!(other instanceof ContentChunkInfo)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
ContentChunkInfo otherCci = (ContentChunkInfo) other;
|
||||
return (this.start == otherCci.start && this.end == otherCci.end);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -20,6 +20,7 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.server.NotAcceptableStatusException;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
|
@ -89,15 +90,15 @@ abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTy
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj != null && getClass() == obj.getClass()) {
|
||||
AbstractMediaTypeExpression other = (AbstractMediaTypeExpression) obj;
|
||||
return (this.mediaType.equals(other.mediaType) && this.isNegated == other.isNegated);
|
||||
if (other == null || getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
AbstractMediaTypeExpression otherExpr = (AbstractMediaTypeExpression) other;
|
||||
return (this.mediaType.equals(otherExpr.mediaType) && this.isNegated == otherExpr.isNegated);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -91,19 +91,16 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
|
|||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj != null && obj instanceof AbstractNameValueExpression) {
|
||||
AbstractNameValueExpression<?> other = (AbstractNameValueExpression<?>) obj;
|
||||
String thisName = isCaseSensitiveName() ? this.name : this.name.toLowerCase();
|
||||
String otherName = isCaseSensitiveName() ? other.name : other.name.toLowerCase();
|
||||
return ((thisName.equalsIgnoreCase(otherName)) &&
|
||||
(this.value != null ? this.value.equals(other.value) : other.value == null) &&
|
||||
this.isNegated == other.isNegated);
|
||||
if (other == null || getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
AbstractNameValueExpression<?> that = (AbstractNameValueExpression<?>) other;
|
||||
return ((isCaseSensitiveName() ? this.name.equals(that.name) : this.name.equalsIgnoreCase(that.name)) &&
|
||||
ObjectUtils.nullSafeEquals(this.value, that.value) && this.isNegated == that.isNegated);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -133,4 +130,5 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
|
|||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ package org.springframework.web.reactive.result.condition;
|
|||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A base class for {@link RequestCondition} types providing implementations of
|
||||
* {@link #equals(Object)}, {@link #hashCode()}, and {@link #toString()}.
|
||||
|
|
@ -26,19 +28,17 @@ import java.util.Iterator;
|
|||
* @author Rossen Stoyanchev
|
||||
* @since 5.0
|
||||
*/
|
||||
public abstract class AbstractRequestCondition<T extends AbstractRequestCondition<T>>
|
||||
implements RequestCondition<T> {
|
||||
public abstract class AbstractRequestCondition<T extends AbstractRequestCondition<T>> implements RequestCondition<T> {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj != null && getClass() == obj.getClass()) {
|
||||
AbstractRequestCondition<?> other = (AbstractRequestCondition<?>) obj;
|
||||
return getContent().equals(other.getContent());
|
||||
if (other == null || getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
return getContent().equals(((AbstractRequestCondition<?>) other).getContent());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -91,7 +91,7 @@ public class CompositeRequestCondition extends AbstractRequestCondition<Composit
|
|||
|
||||
@Override
|
||||
protected Collection<?> getContent() {
|
||||
return (isEmpty()) ? Collections.emptyList() : getConditions();
|
||||
return (!isEmpty() ? getConditions() : Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition<Con
|
|||
*/
|
||||
@Override
|
||||
public ConsumesRequestCondition combine(ConsumesRequestCondition other) {
|
||||
return !other.expressions.isEmpty() ? other : this;
|
||||
return (!other.expressions.isEmpty() ? other : this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -168,7 +168,7 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition<Con
|
|||
}
|
||||
Set<ConsumeMediaTypeExpression> result = new LinkedHashSet<>(expressions);
|
||||
result.removeIf(expression -> !expression.match(exchange));
|
||||
return (result.isEmpty()) ? null : new ConsumesRequestCondition(result);
|
||||
return (!result.isEmpty() ? new ConsumesRequestCondition(result) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -56,14 +56,9 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
|
|||
* Creates a new instance with the given {@code Stream} of URL patterns.
|
||||
*/
|
||||
public PatternsRequestCondition(List<PathPattern> patterns) {
|
||||
this(toSortedSet(patterns));
|
||||
this(new TreeSet<>(patterns));
|
||||
}
|
||||
|
||||
private static SortedSet<PathPattern> toSortedSet(Collection<PathPattern> patterns) {
|
||||
TreeSet<PathPattern> sorted = new TreeSet<>();
|
||||
sorted.addAll(patterns);
|
||||
return sorted;
|
||||
}
|
||||
|
||||
private PatternsRequestCondition(SortedSet<PathPattern> patterns) {
|
||||
this.patterns = patterns;
|
||||
|
|
@ -127,8 +122,7 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
|
|||
return this;
|
||||
}
|
||||
SortedSet<PathPattern> matches = getMatchingPatterns(exchange);
|
||||
return matches.isEmpty() ? null :
|
||||
new PatternsRequestCondition(matches);
|
||||
return (!matches.isEmpty() ? new PatternsRequestCondition(matches) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
|
|||
}
|
||||
Set<ProduceMediaTypeExpression> result = new LinkedHashSet<>(expressions);
|
||||
result.removeIf(expression -> !expression.match(exchange));
|
||||
return (result.isEmpty()) ? null : new ProducesRequestCondition(result, this.contentTypeResolver);
|
||||
return (!result.isEmpty() ? new ProducesRequestCondition(result, this.contentTypeResolver) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -273,7 +273,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
|
|||
ProduceMediaTypeExpression expr1 = condition1.getExpressionsToCompare().get(index1);
|
||||
ProduceMediaTypeExpression expr2 = condition2.getExpressionsToCompare().get(index2);
|
||||
result = expr1.compareTo(expr2);
|
||||
result = (result != 0) ? result : expr1.getMediaType().compareTo(expr2.getMediaType());
|
||||
result = (result != 0 ? result : expr1.getMediaType().compareTo(expr2.getMediaType()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -128,10 +128,10 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
|||
* @param exchange the current exchange
|
||||
* @param bindingContext the binding context to use
|
||||
* @param providedArgs optional list of argument values to match by type
|
||||
* @return Mono with a {@link HandlerResult}.
|
||||
* @return a Mono with a {@link HandlerResult}.
|
||||
*/
|
||||
public Mono<HandlerResult> invoke(ServerWebExchange exchange, BindingContext bindingContext,
|
||||
Object... providedArgs) {
|
||||
public Mono<HandlerResult> invoke(
|
||||
ServerWebExchange exchange, BindingContext bindingContext, Object... providedArgs) {
|
||||
|
||||
return resolveArguments(exchange, bindingContext, providedArgs).flatMap(args -> {
|
||||
try {
|
||||
|
|
@ -162,8 +162,8 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
|||
});
|
||||
}
|
||||
|
||||
private Mono<Object[]> resolveArguments(ServerWebExchange exchange, BindingContext bindingContext,
|
||||
Object... providedArgs) {
|
||||
private Mono<Object[]> resolveArguments(
|
||||
ServerWebExchange exchange, BindingContext bindingContext, Object... providedArgs) {
|
||||
|
||||
if (ObjectUtils.isEmpty(getMethodParameters())) {
|
||||
return EMPTY_ARGS;
|
||||
|
|
|
|||
|
|
@ -487,8 +487,8 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
|||
public RequestMappingInfo build() {
|
||||
RequestedContentTypeResolver contentTypeResolver = this.options.getContentTypeResolver();
|
||||
|
||||
PathPatternParser parser = this.options.getPatternParser() != null ?
|
||||
this.options.getPatternParser() : new PathPatternParser();
|
||||
PathPatternParser parser = (this.options.getPatternParser() != null ?
|
||||
this.options.getPatternParser() : new PathPatternParser());
|
||||
PatternsRequestCondition patternsCondition = new PatternsRequestCondition(parse(this.paths, parser));
|
||||
|
||||
return new RequestMappingInfo(this.mappingName, patternsCondition,
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ public abstract class AbstractMessageReaderArgumentResolver extends HandlerMetho
|
|||
* @param messageReaders readers to convert from the request body
|
||||
* @param adapterRegistry for adapting to other reactive types from Flux and Mono
|
||||
*/
|
||||
protected AbstractMessageReaderArgumentResolver(List<HttpMessageReader<?>> messageReaders,
|
||||
ReactiveAdapterRegistry adapterRegistry) {
|
||||
protected AbstractMessageReaderArgumentResolver(
|
||||
List<HttpMessageReader<?>> messageReaders, ReactiveAdapterRegistry adapterRegistry) {
|
||||
|
||||
super(adapterRegistry);
|
||||
Assert.notEmpty(messageReaders, "At least one HttpMessageReader is required");
|
||||
|
|
@ -121,6 +121,7 @@ public abstract class AbstractMessageReaderArgumentResolver extends HandlerMetho
|
|||
*/
|
||||
protected Mono<Object> readBody(MethodParameter bodyParameter, boolean isBodyRequired,
|
||||
BindingContext bindingContext, ServerWebExchange exchange) {
|
||||
|
||||
return this.readBody(bodyParameter, null, isBodyRequired, bindingContext, exchange);
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +140,7 @@ public abstract class AbstractMessageReaderArgumentResolver extends HandlerMetho
|
|||
boolean isBodyRequired, BindingContext bindingContext, ServerWebExchange exchange) {
|
||||
|
||||
ResolvableType bodyType = ResolvableType.forMethodParameter(bodyParam);
|
||||
ResolvableType actualType = actualParam == null ? bodyType : ResolvableType.forMethodParameter(actualParam);
|
||||
ResolvableType actualType = (actualParam != null ? ResolvableType.forMethodParameter(actualParam) : bodyType);
|
||||
Class<?> resolvedType = bodyType.resolve();
|
||||
ReactiveAdapter adapter = (resolvedType != null ? getAdapterRegistry().getAdapter(resolvedType) : null);
|
||||
ResolvableType elementType = (adapter != null ? bodyType.getGeneric() : bodyType);
|
||||
|
|
@ -179,7 +180,7 @@ public abstract class AbstractMessageReaderArgumentResolver extends HandlerMetho
|
|||
mono = mono.doOnNext(target ->
|
||||
validate(target, hints, bodyParam, bindingContext, exchange));
|
||||
}
|
||||
return adapter != null ? Mono.just(adapter.fromPublisher(mono)) : Mono.from(mono);
|
||||
return (adapter != null ? Mono.just(adapter.fromPublisher(mono)) : Mono.from(mono));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,8 +103,8 @@ public abstract class AbstractMessageWriterResultHandler extends HandlerResultHa
|
|||
* Write a given body to the response with {@link HttpMessageWriter}.
|
||||
* @param body the object to write
|
||||
* @param bodyParameter the {@link MethodParameter} of the body to write
|
||||
* @param actualParameter the actual return type of the method that returned the
|
||||
* value; could be different from {@code bodyParameter} when processing {@code HttpEntity}
|
||||
* @param actualParam the actual return type of the method that returned the value;
|
||||
* could be different from {@code bodyParameter} when processing {@code HttpEntity}
|
||||
* for example
|
||||
* @param exchange the current exchange
|
||||
* @return indicates completion or error
|
||||
|
|
@ -112,11 +112,10 @@ public abstract class AbstractMessageWriterResultHandler extends HandlerResultHa
|
|||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
protected Mono<Void> writeBody(@Nullable Object body, MethodParameter bodyParameter,
|
||||
@Nullable MethodParameter actualParameter, ServerWebExchange exchange) {
|
||||
@Nullable MethodParameter actualParam, ServerWebExchange exchange) {
|
||||
|
||||
ResolvableType bodyType = ResolvableType.forMethodParameter(bodyParameter);
|
||||
ResolvableType actualType = (actualParameter == null ?
|
||||
bodyType : ResolvableType.forMethodParameter(actualParameter));
|
||||
ResolvableType actualType = (actualParam != null ? ResolvableType.forMethodParameter(actualParam) : bodyType);
|
||||
Class<?> bodyClass = bodyType.resolve();
|
||||
ReactiveAdapter adapter = getAdapterRegistry().getAdapter(bodyClass, body);
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -40,9 +40,7 @@ import org.springframework.web.server.ServerWebExchange;
|
|||
*/
|
||||
public class HttpEntityArgumentResolver extends AbstractMessageReaderArgumentResolver {
|
||||
|
||||
public HttpEntityArgumentResolver(List<HttpMessageReader<?>> readers,
|
||||
ReactiveAdapterRegistry registry) {
|
||||
|
||||
public HttpEntityArgumentResolver(List<HttpMessageReader<?>> readers, ReactiveAdapterRegistry registry) {
|
||||
super(readers, registry);
|
||||
}
|
||||
|
||||
|
|
@ -64,9 +62,9 @@ public class HttpEntityArgumentResolver extends AbstractMessageReaderArgumentRes
|
|||
}
|
||||
|
||||
private Object createEntity(@Nullable Object body, Class<?> entityType, ServerHttpRequest request) {
|
||||
return RequestEntity.class.equals(entityType) ?
|
||||
return (RequestEntity.class.equals(entityType) ?
|
||||
new RequestEntity<>(body, request.getHeaders(), request.getMethod(), request.getURI()) :
|
||||
new HttpEntity<>(body, request.getHeaders());
|
||||
new HttpEntity<>(body, request.getHeaders()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -36,7 +36,6 @@ import org.springframework.web.server.ServerWebExchange;
|
|||
*/
|
||||
public class PrincipalArgumentResolver extends HandlerMethodArgumentResolverSupport {
|
||||
|
||||
|
||||
public PrincipalArgumentResolver(ReactiveAdapterRegistry adapterRegistry) {
|
||||
super(adapterRegistry);
|
||||
}
|
||||
|
|
@ -48,12 +47,12 @@ public class PrincipalArgumentResolver extends HandlerMethodArgumentResolverSupp
|
|||
}
|
||||
|
||||
@Override
|
||||
public Mono<Object> resolveArgument(MethodParameter parameter, BindingContext context,
|
||||
ServerWebExchange exchange) {
|
||||
public Mono<Object> resolveArgument(
|
||||
MethodParameter parameter, BindingContext context, ServerWebExchange exchange) {
|
||||
|
||||
Mono<Principal> principal = exchange.getPrincipal();
|
||||
ReactiveAdapter adapter = getAdapterRegistry().getAdapter(parameter.getParameterType());
|
||||
return adapter != null ? Mono.just(adapter.fromPublisher(principal)) : Mono.from(principal);
|
||||
return (adapter != null ? Mono.just(adapter.fromPublisher(principal)) : Mono.from(principal));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,24 +51,20 @@ import org.springframework.web.server.ServerWebInputException;
|
|||
*/
|
||||
public class RequestPartMethodArgumentResolver extends AbstractMessageReaderArgumentResolver {
|
||||
|
||||
|
||||
public RequestPartMethodArgumentResolver(List<HttpMessageReader<?>> readers,
|
||||
ReactiveAdapterRegistry registry) {
|
||||
|
||||
public RequestPartMethodArgumentResolver(List<HttpMessageReader<?>> readers, ReactiveAdapterRegistry registry) {
|
||||
super(readers, registry);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(MethodParameter parameter) {
|
||||
return parameter.hasParameterAnnotation(RequestPart.class) ||
|
||||
checkParameterType(parameter, Part.class::isAssignableFrom);
|
||||
return (parameter.hasParameterAnnotation(RequestPart.class) ||
|
||||
checkParameterType(parameter, Part.class::isAssignableFrom));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Mono<Object> resolveArgument(MethodParameter parameter, BindingContext bindingContext,
|
||||
ServerWebExchange exchange) {
|
||||
public Mono<Object> resolveArgument(
|
||||
MethodParameter parameter, BindingContext bindingContext, ServerWebExchange exchange) {
|
||||
|
||||
RequestPart requestPart = parameter.getParameterAnnotation(RequestPart.class);
|
||||
boolean isRequired = (requestPart == null || requestPart.required());
|
||||
|
|
@ -78,9 +74,7 @@ public class RequestPartMethodArgumentResolver extends AbstractMessageReaderArgu
|
|||
.flatMapMany(map -> {
|
||||
List<Part> parts = map.get(name);
|
||||
if (CollectionUtils.isEmpty(parts)) {
|
||||
return isRequired ?
|
||||
Flux.error(getMissingPartException(name, parameter)) :
|
||||
Flux.empty();
|
||||
return (isRequired ? Flux.error(getMissingPartException(name, parameter)) : Flux.empty());
|
||||
}
|
||||
return Flux.fromIterable(parts);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -102,12 +102,12 @@ public class ServerWebExchangeArgumentResolver extends HandlerMethodArgumentReso
|
|||
else if (TimeZone.class == paramType) {
|
||||
LocaleContext localeContext = exchange.getLocaleContext();
|
||||
TimeZone timeZone = getTimeZone(localeContext);
|
||||
return timeZone != null ? timeZone : TimeZone.getDefault();
|
||||
return (timeZone != null ? timeZone : TimeZone.getDefault());
|
||||
}
|
||||
else if (ZoneId.class == paramType) {
|
||||
LocaleContext localeContext = exchange.getLocaleContext();
|
||||
TimeZone timeZone = getTimeZone(localeContext);
|
||||
return timeZone != null ? timeZone.toZoneId() : ZoneId.systemDefault();
|
||||
return (timeZone != null ? timeZone.toZoneId() : ZoneId.systemDefault());
|
||||
}
|
||||
else if (UriBuilder.class == paramType || UriComponentsBuilder.class == paramType) {
|
||||
URI uri = exchange.getRequest().getURI();
|
||||
|
|
|
|||
|
|
@ -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 class WebSessionArgumentResolver extends HandlerMethodArgumentResolverSup
|
|||
|
||||
Mono<WebSession> session = exchange.getSession();
|
||||
ReactiveAdapter adapter = getAdapterRegistry().getAdapter(parameter.getParameterType());
|
||||
return adapter != null ? Mono.just(adapter.fromPublisher(session)) : Mono.from(session);
|
||||
return (adapter != null ? Mono.just(adapter.fromPublisher(session)) : Mono.from(session));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -61,7 +61,7 @@ public class HttpMessageWriterView implements View {
|
|||
* Constructor with a fully initialized {@link HttpMessageWriter}.
|
||||
*/
|
||||
public HttpMessageWriterView(HttpMessageWriter<?> writer) {
|
||||
Assert.notNull(writer, "'writer' is required.");
|
||||
Assert.notNull(writer, "HttpMessageWriter is required");
|
||||
this.writer = writer;
|
||||
this.canWriteMap = writer.canWrite(ResolvableType.forClass(Map.class), null);
|
||||
}
|
||||
|
|
@ -113,13 +113,11 @@ public class HttpMessageWriterView implements View {
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Mono<Void> render(@Nullable Map<String, ?> model, @Nullable MediaType contentType,
|
||||
ServerWebExchange exchange) {
|
||||
public Mono<Void> render(
|
||||
@Nullable Map<String, ?> model, @Nullable MediaType contentType, ServerWebExchange exchange) {
|
||||
|
||||
Object value = getObjectToRender(model);
|
||||
return (value != null) ?
|
||||
write(value, contentType, exchange) :
|
||||
exchange.getResponse().setComplete();
|
||||
return (value != null ? write(value, contentType, exchange) : exchange.getResponse().setComplete());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -196,7 +196,7 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
|
|||
}
|
||||
if (this.resourceLoaderPaths == null) {
|
||||
String resourceLoaderPath = viewConfig.getResourceLoaderPath();
|
||||
setResourceLoaderPath(resourceLoaderPath == null ? DEFAULT_RESOURCE_LOADER_PATH : resourceLoaderPath);
|
||||
setResourceLoaderPath(resourceLoaderPath != null ? resourceLoaderPath : DEFAULT_RESOURCE_LOADER_PATH);
|
||||
}
|
||||
if (this.sharedEngine == null && viewConfig.isSharedEngine() != null) {
|
||||
this.sharedEngine = viewConfig.isSharedEngine();
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ public abstract class AbstractListenerWebSocketSession<T> extends AbstractWebSoc
|
|||
* @param handshakeInfo the handshake info
|
||||
* @param bufferFactory the DataBuffer factor for the current connection
|
||||
*/
|
||||
public AbstractListenerWebSocketSession(T delegate, String id, HandshakeInfo handshakeInfo,
|
||||
DataBufferFactory bufferFactory) {
|
||||
public AbstractListenerWebSocketSession(
|
||||
T delegate, String id, HandshakeInfo handshakeInfo, DataBufferFactory bufferFactory) {
|
||||
|
||||
this(delegate, id, handshakeInfo, bufferFactory, null);
|
||||
}
|
||||
|
|
@ -105,9 +105,8 @@ public abstract class AbstractListenerWebSocketSession<T> extends AbstractWebSoc
|
|||
|
||||
@Override
|
||||
public Flux<WebSocketMessage> receive() {
|
||||
return canSuspendReceiving() ?
|
||||
Flux.from(this.receivePublisher) :
|
||||
Flux.from(this.receivePublisher).onBackpressureBuffer(RECEIVE_BUFFER_SIZE);
|
||||
return (canSuspendReceiving() ? Flux.from(this.receivePublisher) :
|
||||
Flux.from(this.receivePublisher).onBackpressureBuffer(RECEIVE_BUFFER_SIZE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue