Polishing
This commit is contained in:
parent
b68e692854
commit
40efcc933c
|
|
@ -291,20 +291,20 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||||
// unadvised but can return this). May be required to expose the proxy.
|
// unadvised but can return this). May be required to expose the proxy.
|
||||||
Callback targetInterceptor;
|
Callback targetInterceptor;
|
||||||
if (exposeProxy) {
|
if (exposeProxy) {
|
||||||
targetInterceptor = isStatic ?
|
targetInterceptor = (isStatic ?
|
||||||
new StaticUnadvisedExposedInterceptor(this.advised.getTargetSource().getTarget()) :
|
new StaticUnadvisedExposedInterceptor(this.advised.getTargetSource().getTarget()) :
|
||||||
new DynamicUnadvisedExposedInterceptor(this.advised.getTargetSource());
|
new DynamicUnadvisedExposedInterceptor(this.advised.getTargetSource()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
targetInterceptor = isStatic ?
|
targetInterceptor = (isStatic ?
|
||||||
new StaticUnadvisedInterceptor(this.advised.getTargetSource().getTarget()) :
|
new StaticUnadvisedInterceptor(this.advised.getTargetSource().getTarget()) :
|
||||||
new DynamicUnadvisedInterceptor(this.advised.getTargetSource());
|
new DynamicUnadvisedInterceptor(this.advised.getTargetSource()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Choose a "direct to target" dispatcher (used for
|
// Choose a "direct to target" dispatcher (used for
|
||||||
// unadvised calls to static targets that cannot return this).
|
// unadvised calls to static targets that cannot return this).
|
||||||
Callback targetDispatcher = isStatic ?
|
Callback targetDispatcher = (isStatic ?
|
||||||
new StaticDispatcher(this.advised.getTargetSource().getTarget()) : new SerializableNoOp();
|
new StaticDispatcher(this.advised.getTargetSource().getTarget()) : new SerializableNoOp());
|
||||||
|
|
||||||
Callback[] mainCallbacks = new Callback[] {
|
Callback[] mainCallbacks = new Callback[] {
|
||||||
aopInterceptor, // for normal advice
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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;
|
return false;
|
||||||
}
|
}
|
||||||
ControlFlowPointcut that = (ControlFlowPointcut) other;
|
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
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -144,14 +144,14 @@ public abstract class MethodMatchers {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof UnionMethodMatcher)) {
|
if (!(other instanceof UnionMethodMatcher)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
UnionMethodMatcher that = (UnionMethodMatcher) obj;
|
UnionMethodMatcher that = (UnionMethodMatcher) other;
|
||||||
return (this.mm1.equals(that.mm1) && this.mm2.equals(that.mm2));
|
return (this.mm1.equals(that.mm1) && this.mm2.equals(that.mm2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -239,18 +239,18 @@ public abstract class MethodMatchers {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, @Nullable Class<?> targetClass, boolean hasIntroductions) {
|
public boolean matches(Method method, @Nullable Class<?> targetClass, boolean hasIntroductions) {
|
||||||
return MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions) &&
|
return (MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions) &&
|
||||||
MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions);
|
MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, @Nullable Class<?> targetClass) {
|
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
|
@Override
|
||||||
public boolean isRuntime() {
|
public boolean isRuntime() {
|
||||||
return this.mm1.isRuntime() || this.mm2.isRuntime();
|
return (this.mm1.isRuntime() || this.mm2.isRuntime());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -258,10 +258,10 @@ public abstract class MethodMatchers {
|
||||||
// Because a dynamic intersection may be composed of a static and dynamic part,
|
// 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
|
// we must avoid calling the 3-arg matches method on a dynamic matcher, as
|
||||||
// it will probably be an unsupported operation.
|
// it will probably be an unsupported operation.
|
||||||
boolean aMatches = this.mm1.isRuntime() ?
|
boolean aMatches = (this.mm1.isRuntime() ?
|
||||||
this.mm1.matches(method, targetClass, args) : this.mm1.matches(method, targetClass);
|
this.mm1.matches(method, targetClass, args) : this.mm1.matches(method, targetClass));
|
||||||
boolean bMatches = this.mm2.isRuntime() ?
|
boolean bMatches = (this.mm2.isRuntime() ?
|
||||||
this.mm2.matches(method, targetClass, args) : this.mm2.matches(method, targetClass);
|
this.mm2.matches(method, targetClass, args) : this.mm2.matches(method, targetClass));
|
||||||
return aMatches && bMatches;
|
return aMatches && bMatches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -348,14 +348,8 @@ public class MutablePropertyValues implements PropertyValues, Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (this == other) {
|
return (this == other || (other instanceof MutablePropertyValues &&
|
||||||
return true;
|
this.propertyValueList.equals(((MutablePropertyValues) other).propertyValueList)));
|
||||||
}
|
|
||||||
if (!(other instanceof MutablePropertyValues)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
MutablePropertyValues that = (MutablePropertyValues) other;
|
|
||||||
return this.propertyValueList.equals(that.propertyValueList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ public class CannotLoadBeanClassException extends FatalBeanException {
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String resourceDescription;
|
private final String resourceDescription;
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private final String beanName;
|
private final String beanName;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
@ -47,8 +46,8 @@ public class CannotLoadBeanClassException extends FatalBeanException {
|
||||||
* @param beanClassName the name of the bean class
|
* @param beanClassName the name of the bean class
|
||||||
* @param cause the root cause
|
* @param cause the root cause
|
||||||
*/
|
*/
|
||||||
public CannotLoadBeanClassException(
|
public CannotLoadBeanClassException(@Nullable String resourceDescription, String beanName,
|
||||||
@Nullable String resourceDescription, String beanName, @Nullable String beanClassName, ClassNotFoundException cause) {
|
@Nullable String beanClassName, ClassNotFoundException cause) {
|
||||||
|
|
||||||
super("Cannot find class [" + beanClassName + "] for bean with name '" + beanName + "'" +
|
super("Cannot find class [" + beanClassName + "] for bean with name '" + beanName + "'" +
|
||||||
(resourceDescription != null ? " defined in " + resourceDescription : ""), cause);
|
(resourceDescription != null ? " defined in " + resourceDescription : ""), cause);
|
||||||
|
|
@ -65,8 +64,8 @@ public class CannotLoadBeanClassException extends FatalBeanException {
|
||||||
* @param beanClassName the name of the bean class
|
* @param beanClassName the name of the bean class
|
||||||
* @param cause the root cause
|
* @param cause the root cause
|
||||||
*/
|
*/
|
||||||
public CannotLoadBeanClassException(
|
public CannotLoadBeanClassException(@Nullable String resourceDescription, String beanName,
|
||||||
@Nullable String resourceDescription, String beanName, @Nullable String beanClassName, LinkageError cause) {
|
@Nullable String beanClassName, LinkageError cause) {
|
||||||
|
|
||||||
super("Error loading class [" + beanClassName + "] for bean with name '" + beanName + "'" +
|
super("Error loading class [" + beanClassName + "] for bean with name '" + beanName + "'" +
|
||||||
(resourceDescription != null ? " defined in " + resourceDescription : "") +
|
(resourceDescription != null ? " defined in " + resourceDescription : "") +
|
||||||
|
|
@ -89,7 +88,6 @@ public class CannotLoadBeanClassException extends FatalBeanException {
|
||||||
/**
|
/**
|
||||||
* Return the name of the bean requested.
|
* Return the name of the bean requested.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
|
||||||
public String getBeanName() {
|
public String getBeanName() {
|
||||||
return this.beanName;
|
return this.beanName;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ public class FieldRetrievingFactoryBean
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to get the exact method first.
|
// 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);
|
this.fieldObject = targetClass.getField(this.targetField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -374,7 +374,6 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
|
||||||
if (args[0] == null) {
|
if (args[0] == null) {
|
||||||
throw new IllegalArgumentException("Argument to ref() is not a valid bean or was not found");
|
throw new IllegalArgumentException("Argument to ref() is not a valid bean or was not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0] instanceof RuntimeBeanReference) {
|
if (args[0] instanceof RuntimeBeanReference) {
|
||||||
refName = ((RuntimeBeanReference) args[0]).getBeanName();
|
refName = ((RuntimeBeanReference) args[0]).getBeanName();
|
||||||
}
|
}
|
||||||
|
|
@ -490,11 +489,11 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
|
||||||
Map.Entry factoryBeanEntry = (Map.Entry) ((Map) args[0]).entrySet().iterator().next();
|
Map.Entry factoryBeanEntry = (Map.Entry) ((Map) args[0]).entrySet().iterator().next();
|
||||||
// If we have a closure body, that will be the last argument.
|
// If we have a closure body, that will be the last argument.
|
||||||
// In between are the constructor args
|
// 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 we have more than this number of args, we have constructor args
|
||||||
if (args.length > constructorArgsTest){
|
if (args.length > constructorArgsTest){
|
||||||
// factory-method requires args
|
// 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,
|
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, null,
|
||||||
resolveConstructorArguments(args, 1, endOfConstructArgs));
|
resolveConstructorArguments(args, 1, endOfConstructArgs));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -82,7 +82,7 @@ public final class ParseState {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Entry peek() {
|
public Entry peek() {
|
||||||
return this.state.isEmpty() ? null : this.state.peek();
|
return this.state.peek();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1114,39 +1114,38 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||||
public abstract AbstractBeanDefinition cloneBeanDefinition();
|
public abstract AbstractBeanDefinition cloneBeanDefinition();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof AbstractBeanDefinition)) {
|
if (!(other instanceof AbstractBeanDefinition)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
AbstractBeanDefinition other = (AbstractBeanDefinition) obj;
|
AbstractBeanDefinition that = (AbstractBeanDefinition) other;
|
||||||
boolean rtn = true;
|
boolean rtn = ObjectUtils.nullSafeEquals(getBeanClassName(), that.getBeanClassName());
|
||||||
rtn = rtn &= ObjectUtils.nullSafeEquals(getBeanClassName(), other.getBeanClassName());
|
rtn = rtn &= ObjectUtils.nullSafeEquals(this.scope, that.scope);
|
||||||
rtn = rtn &= ObjectUtils.nullSafeEquals(this.scope, other.scope);
|
rtn = rtn &= this.abstractFlag == that.abstractFlag;
|
||||||
rtn = rtn &= this.abstractFlag == other.abstractFlag;
|
rtn = rtn &= this.lazyInit == that.lazyInit;
|
||||||
rtn = rtn &= this.lazyInit == other.lazyInit;
|
rtn = rtn &= this.autowireMode == that.autowireMode;
|
||||||
rtn = rtn &= this.autowireMode == other.autowireMode;
|
rtn = rtn &= this.dependencyCheck == that.dependencyCheck;
|
||||||
rtn = rtn &= this.dependencyCheck == other.dependencyCheck;
|
rtn = rtn &= Arrays.equals(this.dependsOn, that.dependsOn);
|
||||||
rtn = rtn &= Arrays.equals(this.dependsOn, other.dependsOn);
|
rtn = rtn &= this.autowireCandidate == that.autowireCandidate;
|
||||||
rtn = rtn &= this.autowireCandidate == other.autowireCandidate;
|
rtn = rtn &= ObjectUtils.nullSafeEquals(this.qualifiers, that.qualifiers);
|
||||||
rtn = rtn &= ObjectUtils.nullSafeEquals(this.qualifiers, other.qualifiers);
|
rtn = rtn &= this.primary == that.primary;
|
||||||
rtn = rtn &= this.primary == other.primary;
|
rtn = rtn &= this.nonPublicAccessAllowed == that.nonPublicAccessAllowed;
|
||||||
rtn = rtn &= this.nonPublicAccessAllowed == other.nonPublicAccessAllowed;
|
rtn = rtn &= this.lenientConstructorResolution == that.lenientConstructorResolution;
|
||||||
rtn = rtn &= this.lenientConstructorResolution == other.lenientConstructorResolution;
|
rtn = rtn &= ObjectUtils.nullSafeEquals(this.constructorArgumentValues, that.constructorArgumentValues);
|
||||||
rtn = rtn &= ObjectUtils.nullSafeEquals(this.constructorArgumentValues, other.constructorArgumentValues);
|
rtn = rtn &= ObjectUtils.nullSafeEquals(this.propertyValues, that.propertyValues);
|
||||||
rtn = rtn &= ObjectUtils.nullSafeEquals(this.propertyValues, other.propertyValues);
|
rtn = rtn &= ObjectUtils.nullSafeEquals(this.methodOverrides, that.methodOverrides);
|
||||||
rtn = rtn &= ObjectUtils.nullSafeEquals(this.methodOverrides, other.methodOverrides);
|
rtn = rtn &= ObjectUtils.nullSafeEquals(this.factoryBeanName, that.factoryBeanName);
|
||||||
rtn = rtn &= ObjectUtils.nullSafeEquals(this.factoryBeanName, other.factoryBeanName);
|
rtn = rtn &= ObjectUtils.nullSafeEquals(this.factoryMethodName, that.factoryMethodName);
|
||||||
rtn = rtn &= ObjectUtils.nullSafeEquals(this.factoryMethodName, other.factoryMethodName);
|
rtn = rtn &= ObjectUtils.nullSafeEquals(this.initMethodName, that.initMethodName);
|
||||||
rtn = rtn &= ObjectUtils.nullSafeEquals(this.initMethodName, other.initMethodName);
|
rtn = rtn &= this.enforceInitMethod == that.enforceInitMethod;
|
||||||
rtn = rtn &= this.enforceInitMethod == other.enforceInitMethod;
|
rtn = rtn &= ObjectUtils.nullSafeEquals(this.destroyMethodName, that.destroyMethodName);
|
||||||
rtn = rtn &= ObjectUtils.nullSafeEquals(this.destroyMethodName, other.destroyMethodName);
|
rtn = rtn &= this.enforceDestroyMethod == that.enforceDestroyMethod;
|
||||||
rtn = rtn &= this.enforceDestroyMethod == other.enforceDestroyMethod;
|
rtn = rtn &= this.synthetic == that.synthetic;
|
||||||
rtn = rtn &= this.synthetic == other.synthetic;
|
rtn = rtn &= this.role == that.role;
|
||||||
rtn = rtn &= this.role == other.role;
|
return rtn && super.equals(other);
|
||||||
return rtn && super.equals(obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.
|
* This implementation compares the underlying BeanDefinition.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (obj == this ||
|
return (this == other || (other instanceof BeanDefinitionResource &&
|
||||||
(obj instanceof BeanDefinitionResource &&
|
((BeanDefinitionResource) other).beanDefinition.equals(this.beanDefinition)));
|
||||||
((BeanDefinitionResource) obj).beanDefinition.equals(this.beanDefinition)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1521,8 +1521,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||||
isAutowireCandidate(beanName, mbd, descriptor, getAutowireCandidateResolver())) {
|
isAutowireCandidate(beanName, mbd, descriptor, getAutowireCandidateResolver())) {
|
||||||
// Probably a proxy interfering with target type match -> throw meaningful exception.
|
// Probably a proxy interfering with target type match -> throw meaningful exception.
|
||||||
Object beanInstance = getSingleton(beanName, false);
|
Object beanInstance = getSingleton(beanName, false);
|
||||||
Class<?> beanType = (beanInstance != null && beanInstance.getClass() != NullBean.class) ?
|
Class<?> beanType = (beanInstance != null && beanInstance.getClass() != NullBean.class ?
|
||||||
beanInstance.getClass() : predictBeanType(beanName, mbd);
|
beanInstance.getClass() : predictBeanType(beanName, mbd));
|
||||||
if (beanType != null && !type.isAssignableFrom(beanType)) {
|
if (beanType != null && !type.isAssignableFrom(beanType)) {
|
||||||
throw new BeanNotOfRequiredTypeException(beanName, type, beanType);
|
throw new BeanNotOfRequiredTypeException(beanName, type, beanType);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -900,9 +900,9 @@ public class BeanDefinitionParserDelegate {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Object parsePropertyValue(Element ele, BeanDefinition bd, @Nullable String propertyName) {
|
public Object parsePropertyValue(Element ele, BeanDefinition bd, @Nullable String propertyName) {
|
||||||
String elementName = (propertyName != null) ?
|
String elementName = (propertyName != null ?
|
||||||
"<property> element for property '" + propertyName + "'" :
|
"<property> element for property '" + propertyName + "'" :
|
||||||
"<constructor-arg> element";
|
"<constructor-arg> element");
|
||||||
|
|
||||||
// Should only have one child element: ref, value, list, etc.
|
// Should only have one child element: ref, value, list, etc.
|
||||||
NodeList nl = ele.getChildNodes();
|
NodeList nl = ele.getChildNodes();
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,7 @@ import javax.lang.model.element.TypeElement;
|
||||||
public class CandidateComponentsIndexer implements Processor {
|
public class CandidateComponentsIndexer implements Processor {
|
||||||
|
|
||||||
private static final Set<ElementKind> TYPE_KINDS =
|
private static final Set<ElementKind> TYPE_KINDS =
|
||||||
Collections.unmodifiableSet(EnumSet.of(ElementKind.CLASS,
|
Collections.unmodifiableSet(EnumSet.of(ElementKind.CLASS, ElementKind.INTERFACE));
|
||||||
ElementKind.INTERFACE));
|
|
||||||
|
|
||||||
private MetadataStore metadataStore;
|
private MetadataStore metadataStore;
|
||||||
|
|
||||||
|
|
@ -135,10 +134,9 @@ public class CandidateComponentsIndexer implements Processor {
|
||||||
|
|
||||||
private static List<TypeElement> staticTypesIn(Iterable<? extends Element> elements) {
|
private static List<TypeElement> staticTypesIn(Iterable<? extends Element> elements) {
|
||||||
List<TypeElement> list = new ArrayList<>();
|
List<TypeElement> list = new ArrayList<>();
|
||||||
for (Element e : elements) {
|
for (Element element : elements) {
|
||||||
if (TYPE_KINDS.contains(e.getKind())
|
if (TYPE_KINDS.contains(element.getKind()) && element.getModifiers().contains(Modifier.STATIC)) {
|
||||||
&& e.getModifiers().contains(Modifier.STATIC)) {
|
list.add(TypeElement.class.cast(element));
|
||||||
list.add(TypeElement.class.cast(e));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package org.springframework.cache.jcache.interceptor;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -32,8 +33,6 @@ import org.springframework.cache.interceptor.CacheResolver;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ExceptionTypeFilter;
|
import org.springframework.util.ExceptionTypeFilter;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A base {@link JCacheOperation} implementation.
|
* A base {@link JCacheOperation} implementation.
|
||||||
*
|
*
|
||||||
|
|
@ -56,8 +55,8 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
||||||
* @param cacheResolver the cache resolver to resolve regular caches
|
* @param cacheResolver the cache resolver to resolve regular caches
|
||||||
*/
|
*/
|
||||||
protected AbstractJCacheOperation(CacheMethodDetails<A> methodDetails, CacheResolver cacheResolver) {
|
protected AbstractJCacheOperation(CacheMethodDetails<A> methodDetails, CacheResolver cacheResolver) {
|
||||||
Assert.notNull(methodDetails, "method details must not be null.");
|
Assert.notNull(methodDetails, "CacheMethodDetails must not be null");
|
||||||
Assert.notNull(cacheResolver, "cache resolver must not be null.");
|
Assert.notNull(cacheResolver, "CacheResolver must not be null");
|
||||||
this.methodDetails = methodDetails;
|
this.methodDetails = methodDetails;
|
||||||
this.cacheResolver = cacheResolver;
|
this.cacheResolver = cacheResolver;
|
||||||
this.allParameterDetails = initializeAllParameterDetails(methodDetails.getMethod());
|
this.allParameterDetails = initializeAllParameterDetails(methodDetails.getMethod());
|
||||||
|
|
@ -117,7 +116,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
||||||
protected ExceptionTypeFilter createExceptionTypeFilter(
|
protected ExceptionTypeFilter createExceptionTypeFilter(
|
||||||
Class<? extends Throwable>[] includes, Class<? extends Throwable>[] excludes) {
|
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
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,12 @@ package org.springframework.cache.jcache.interceptor;
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.cache.annotation.CacheMethodDetails;
|
import javax.cache.annotation.CacheMethodDetails;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default {@link CacheMethodDetails} implementation.
|
* The default {@link CacheMethodDetails} implementation.
|
||||||
*
|
*
|
||||||
|
|
@ -46,7 +45,7 @@ class DefaultCacheMethodDetails<A extends Annotation> implements CacheMethodDeta
|
||||||
public DefaultCacheMethodDetails(Method method, A cacheAnnotation, String cacheName) {
|
public DefaultCacheMethodDetails(Method method, A cacheAnnotation, String cacheName) {
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.annotations = Collections.unmodifiableSet(
|
this.annotations = Collections.unmodifiableSet(
|
||||||
new LinkedHashSet<>(asList(method.getAnnotations())));
|
new LinkedHashSet<>(Arrays.asList(method.getAnnotations())));
|
||||||
this.cacheAnnotation = cacheAnnotation;
|
this.cacheAnnotation = cacheAnnotation;
|
||||||
this.cacheName = cacheName;
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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;
|
return 0;
|
||||||
}
|
}
|
||||||
long diff = getDelay(TimeUnit.MILLISECONDS) - other.getDelay(TimeUnit.MILLISECONDS);
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -759,7 +759,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Scheduler> getObjectType() {
|
public Class<? extends Scheduler> getObjectType() {
|
||||||
return (this.scheduler != null) ? this.scheduler.getClass() : Scheduler.class;
|
return (this.scheduler != null ? this.scheduler.getClass() : Scheduler.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,12 @@ import org.springframework.util.StringUtils;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class SimpleKey implements Serializable {
|
public class SimpleKey implements Serializable {
|
||||||
|
|
||||||
/**
|
/** An empty key. */
|
||||||
* An empty key.
|
|
||||||
*/
|
|
||||||
public static final SimpleKey EMPTY = new SimpleKey();
|
public static final SimpleKey EMPTY = new SimpleKey();
|
||||||
|
|
||||||
|
|
||||||
private final Object[] params;
|
private final Object[] params;
|
||||||
|
|
||||||
private final int hashCode;
|
private final int hashCode;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -52,10 +52,11 @@ public class SimpleKey implements Serializable {
|
||||||
this.hashCode = Arrays.deepHashCode(this.params);
|
this.hashCode = Arrays.deepHashCode(this.params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (this == obj || (obj instanceof SimpleKey
|
return (this == other ||
|
||||||
&& Arrays.deepEquals(this.params, ((SimpleKey) obj).params)));
|
(other instanceof SimpleKey && Arrays.deepEquals(this.params, ((SimpleKey) other).params)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -553,7 +553,7 @@ class ConfigurationClassParser {
|
||||||
for (DeferredImportSelectorHolder deferredImport : deferredImports) {
|
for (DeferredImportSelectorHolder deferredImport : deferredImports) {
|
||||||
Class<? extends Group> group = deferredImport.getImportSelector().getImportGroup();
|
Class<? extends Group> group = deferredImport.getImportSelector().getImportGroup();
|
||||||
DeferredImportSelectorGrouping grouping = groupings.computeIfAbsent(
|
DeferredImportSelectorGrouping grouping = groupings.computeIfAbsent(
|
||||||
(group == null ? deferredImport : group),
|
(group != null ? group : deferredImport),
|
||||||
key -> new DeferredImportSelectorGrouping(createGroup(group)));
|
key -> new DeferredImportSelectorGrouping(createGroup(group)));
|
||||||
grouping.add(deferredImport);
|
grouping.add(deferredImport);
|
||||||
configurationClasses.put(deferredImport.getConfigurationClass().getMetadata(),
|
configurationClasses.put(deferredImport.getConfigurationClass().getMetadata(),
|
||||||
|
|
@ -561,8 +561,7 @@ class ConfigurationClassParser {
|
||||||
}
|
}
|
||||||
for (DeferredImportSelectorGrouping grouping : groupings.values()) {
|
for (DeferredImportSelectorGrouping grouping : groupings.values()) {
|
||||||
grouping.getImports().forEach(entry -> {
|
grouping.getImports().forEach(entry -> {
|
||||||
ConfigurationClass configurationClass = configurationClasses.get(
|
ConfigurationClass configurationClass = configurationClasses.get(entry.getMetadata());
|
||||||
entry.getMetadata());
|
|
||||||
try {
|
try {
|
||||||
processImports(configurationClass, asSourceClass(configurationClass),
|
processImports(configurationClass, asSourceClass(configurationClass),
|
||||||
asSourceClasses(entry.getImportClassName()), false);
|
asSourceClasses(entry.getImportClassName()), false);
|
||||||
|
|
@ -580,8 +579,7 @@ class ConfigurationClassParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Group createGroup(@Nullable Class<? extends Group> type) {
|
private Group createGroup(@Nullable Class<? extends Group> type) {
|
||||||
Class<? extends Group> effectiveType = (type != null ? type
|
Class<? extends Group> effectiveType = (type != null ? type : DefaultDeferredImportSelectorGroup.class);
|
||||||
: DefaultDeferredImportSelectorGroup.class);
|
|
||||||
Group group = BeanUtils.instantiateClass(effectiveType);
|
Group group = BeanUtils.instantiateClass(effectiveType);
|
||||||
ParserStrategyUtils.invokeAwareMethods(group,
|
ParserStrategyUtils.invokeAwareMethods(group,
|
||||||
ConfigurationClassParser.this.environment,
|
ConfigurationClassParser.this.environment,
|
||||||
|
|
|
||||||
|
|
@ -1252,8 +1252,8 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
protected BeanFactory getInternalParentBeanFactory() {
|
protected BeanFactory getInternalParentBeanFactory() {
|
||||||
return (getParent() instanceof ConfigurableApplicationContext) ?
|
return (getParent() instanceof ConfigurableApplicationContext ?
|
||||||
((ConfigurableApplicationContext) getParent()).getBeanFactory() : getParent();
|
((ConfigurableApplicationContext) getParent()).getBeanFactory() : getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1295,8 +1295,8 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
protected MessageSource getInternalParentMessageSource() {
|
protected MessageSource getInternalParentMessageSource() {
|
||||||
return (getParent() instanceof AbstractApplicationContext) ?
|
return (getParent() instanceof AbstractApplicationContext ?
|
||||||
((AbstractApplicationContext) getParent()).messageSource : getParent();
|
((AbstractApplicationContext) getParent()).messageSource : getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,16 +144,16 @@ public class PeriodicTrigger implements Trigger {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof PeriodicTrigger)) {
|
if (!(other instanceof PeriodicTrigger)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PeriodicTrigger other = (PeriodicTrigger) obj;
|
PeriodicTrigger otherTrigger = (PeriodicTrigger) other;
|
||||||
return (this.fixedRate == other.fixedRate && this.initialDelay == other.initialDelay &&
|
return (this.fixedRate == otherTrigger.fixedRate && this.initialDelay == otherTrigger.initialDelay &&
|
||||||
this.period == other.period);
|
this.period == otherTrigger.period);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -715,8 +715,8 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
|
||||||
* @see #doBind(org.springframework.beans.MutablePropertyValues)
|
* @see #doBind(org.springframework.beans.MutablePropertyValues)
|
||||||
*/
|
*/
|
||||||
public void bind(PropertyValues pvs) {
|
public void bind(PropertyValues pvs) {
|
||||||
MutablePropertyValues mpvs = (pvs instanceof MutablePropertyValues) ?
|
MutablePropertyValues mpvs = (pvs instanceof MutablePropertyValues ?
|
||||||
(MutablePropertyValues) pvs : new MutablePropertyValues(pvs);
|
(MutablePropertyValues) pvs : new MutablePropertyValues(pvs));
|
||||||
doBind(mpvs);
|
doBind(mpvs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,14 +93,8 @@ public abstract class AttributeAccessorSupport implements AttributeAccessor, Ser
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (this == other) {
|
return (this == other || (other instanceof AttributeAccessorSupport &&
|
||||||
return true;
|
this.attributes.equals(((AttributeAccessorSupport) other).attributes)));
|
||||||
}
|
|
||||||
if (!(other instanceof AttributeAccessorSupport)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
AttributeAccessorSupport that = (AttributeAccessorSupport) other;
|
|
||||||
return this.attributes.equals(that.attributes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -66,9 +66,9 @@ public abstract class ParameterizedTypeReference<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (this == obj || (obj instanceof ParameterizedTypeReference &&
|
return (this == other || (other instanceof ParameterizedTypeReference &&
|
||||||
this.type.equals(((ParameterizedTypeReference<?>) obj).type)));
|
this.type.equals(((ParameterizedTypeReference<?>) other).type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -164,12 +164,10 @@ public class ReactiveAdapterRegistry {
|
||||||
/**
|
/**
|
||||||
* Return a shared default {@code ReactiveAdapterRegistry} instance, lazily
|
* Return a shared default {@code ReactiveAdapterRegistry} instance, lazily
|
||||||
* building it once needed.
|
* building it once needed.
|
||||||
*
|
|
||||||
* <p><b>NOTE:</b> We highly recommend passing a long-lived, pre-configured
|
* <p><b>NOTE:</b> We highly recommend passing a long-lived, pre-configured
|
||||||
* {@code ReactiveAdapterRegistry} instance for customization purposes.
|
* {@code ReactiveAdapterRegistry} instance for customization purposes.
|
||||||
* This accessor is only meant as a fallback for code paths that want to
|
* 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.
|
* fall back on a default instance if one isn't provided.
|
||||||
*
|
|
||||||
* @return the shared {@code ReactiveAdapterRegistry} instance (never {@code null})
|
* @return the shared {@code ReactiveAdapterRegistry} instance (never {@code null})
|
||||||
* @since 5.0.2
|
* @since 5.0.2
|
||||||
*/
|
*/
|
||||||
|
|
@ -191,7 +189,6 @@ public class ReactiveAdapterRegistry {
|
||||||
private static class ReactorRegistrar {
|
private static class ReactorRegistrar {
|
||||||
|
|
||||||
void registerAdapters(ReactiveAdapterRegistry registry) {
|
void registerAdapters(ReactiveAdapterRegistry registry) {
|
||||||
|
|
||||||
// Register Flux and Mono before Publisher...
|
// Register Flux and Mono before Publisher...
|
||||||
|
|
||||||
registry.registerReactiveType(
|
registry.registerReactiveType(
|
||||||
|
|
@ -280,7 +277,6 @@ public class ReactiveAdapterRegistry {
|
||||||
private static class ReactorJdkFlowAdapterRegistrar {
|
private static class ReactorJdkFlowAdapterRegistrar {
|
||||||
|
|
||||||
void registerAdapter(ReactiveAdapterRegistry registry) throws Exception {
|
void registerAdapter(ReactiveAdapterRegistry registry) throws Exception {
|
||||||
|
|
||||||
// TODO: remove reflection when build requires JDK 9+
|
// TODO: remove reflection when build requires JDK 9+
|
||||||
|
|
||||||
String publisherName = "java.util.concurrent.Flow.Publisher";
|
String publisherName = "java.util.concurrent.Flow.Publisher";
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
|
@ -31,10 +32,7 @@ import org.springframework.util.StringUtils;
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
final class ProfilesParser {
|
abstract class ProfilesParser {
|
||||||
|
|
||||||
private ProfilesParser() {
|
|
||||||
}
|
|
||||||
|
|
||||||
static Profiles parse(String... expressions) {
|
static Profiles parse(String... expressions) {
|
||||||
Assert.notEmpty(expressions, "Must specify at least one profile");
|
Assert.notEmpty(expressions, "Must specify at least one profile");
|
||||||
|
|
@ -46,8 +44,7 @@ final class ProfilesParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Profiles parseExpression(String expression) {
|
private static Profiles parseExpression(String expression) {
|
||||||
Assert.hasText(expression, () ->
|
Assert.hasText(expression, () -> "Invalid profile expression [" + expression + "]: must contain text");
|
||||||
"Invalid profile expression [" + expression + "]: must contain text");
|
|
||||||
StringTokenizer tokens = new StringTokenizer(expression, "()&|!", true);
|
StringTokenizer tokens = new StringTokenizer(expression, "()&|!", true);
|
||||||
return parseTokens(expression, tokens);
|
return parseTokens(expression, tokens);
|
||||||
}
|
}
|
||||||
|
|
@ -88,8 +85,7 @@ final class ProfilesParser {
|
||||||
return merge(expression, elements, operator);
|
return merge(expression, elements, operator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Profiles merge(String expression, List<Profiles> elements,
|
private static Profiles merge(String expression, List<Profiles> elements, @Nullable Operator operator) {
|
||||||
Operator operator) {
|
|
||||||
assertWellFormed(expression, !elements.isEmpty());
|
assertWellFormed(expression, !elements.isEmpty());
|
||||||
if (elements.size() == 1) {
|
if (elements.size() == 1) {
|
||||||
return elements.get(0);
|
return elements.get(0);
|
||||||
|
|
@ -99,18 +95,15 @@ final class ProfilesParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertWellFormed(String expression, boolean wellFormed) {
|
private static void assertWellFormed(String expression, boolean wellFormed) {
|
||||||
Assert.isTrue(wellFormed,
|
Assert.isTrue(wellFormed, () -> "Malformed profile expression [" + expression + "]");
|
||||||
() -> "Malformed profile expression [" + expression + "]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Profiles or(Profiles... profiles) {
|
private static Profiles or(Profiles... profiles) {
|
||||||
return activeProfile -> Arrays.stream(profiles).anyMatch(
|
return activeProfile -> Arrays.stream(profiles).anyMatch(isMatch(activeProfile));
|
||||||
isMatch(activeProfile));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Profiles and(Profiles... profiles) {
|
private static Profiles and(Profiles... profiles) {
|
||||||
return activeProfile -> Arrays.stream(profiles).allMatch(
|
return activeProfile -> Arrays.stream(profiles).allMatch(isMatch(activeProfile));
|
||||||
isMatch(activeProfile));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Profiles not(Profiles profiles) {
|
private static Profiles not(Profiles profiles) {
|
||||||
|
|
@ -125,10 +118,9 @@ final class ProfilesParser {
|
||||||
return profiles -> profiles.matches(activeProfile);
|
return profiles -> profiles.matches(activeProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum Operator {
|
|
||||||
AND,
|
private enum Operator {AND, OR}
|
||||||
OR
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ParsedProfiles implements Profiles {
|
private static class ParsedProfiles implements Profiles {
|
||||||
|
|
||||||
|
|
@ -155,7 +147,6 @@ final class ProfilesParser {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return StringUtils.arrayToDelimitedString(this.expressions, " or ");
|
return StringUtils.arrayToDelimitedString(this.expressions, " or ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,9 +132,9 @@ public abstract class PropertySource<T> {
|
||||||
* <p>No properties other than {@code name} are evaluated.
|
* <p>No properties other than {@code name} are evaluated.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (this == obj || (obj instanceof PropertySource &&
|
return (this == other || (other instanceof PropertySource &&
|
||||||
ObjectUtils.nullSafeEquals(this.name, ((PropertySource<?>) obj).name)));
|
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.
|
* This implementation compares description strings.
|
||||||
* @see #getDescription()
|
* @see #getDescription()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (obj == this ||
|
return (this == other || (other instanceof Resource &&
|
||||||
(obj instanceof Resource && ((Resource) obj).getDescription().equals(getDescription())));
|
((Resource) other).getDescription().equals(getDescription())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -237,4 +228,13 @@ public abstract class AbstractResource implements Resource {
|
||||||
return getDescription().hashCode();
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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[])
|
* @see java.util.Arrays#equals(byte[], byte[])
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (obj == this ||
|
return (this == other || (other instanceof ByteArrayResource &&
|
||||||
(obj instanceof ByteArrayResource && Arrays.equals(((ByteArrayResource) obj).byteArray, this.byteArray)));
|
Arrays.equals(((ByteArrayResource) other).byteArray, this.byteArray)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -244,18 +244,18 @@ public class ClassPathResource extends AbstractFileResolvingResource {
|
||||||
* This implementation compares the underlying class path locations.
|
* This implementation compares the underlying class path locations.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (obj == this) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj instanceof ClassPathResource) {
|
if (!(other instanceof ClassPathResource)) {
|
||||||
ClassPathResource otherRes = (ClassPathResource) obj;
|
return false;
|
||||||
|
}
|
||||||
|
ClassPathResource otherRes = (ClassPathResource) other;
|
||||||
return (this.path.equals(otherRes.path) &&
|
return (this.path.equals(otherRes.path) &&
|
||||||
ObjectUtils.nullSafeEquals(this.classLoader, otherRes.classLoader) &&
|
ObjectUtils.nullSafeEquals(this.classLoader, otherRes.classLoader) &&
|
||||||
ObjectUtils.nullSafeEquals(this.clazz, otherRes.clazz));
|
ObjectUtils.nullSafeEquals(this.clazz, otherRes.clazz));
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This implementation returns the hash code of the underlying
|
* This implementation returns the hash code of the underlying
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.
|
* This implementation compares the underlying description String.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (obj == this ||
|
return (this == other || (other instanceof DescriptiveResource &&
|
||||||
(obj instanceof DescriptiveResource && ((DescriptiveResource) obj).description.equals(this.description)));
|
((DescriptiveResource) other).description.equals(this.description)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -282,9 +282,9 @@ public class FileSystemResource extends AbstractResource implements WritableReso
|
||||||
* This implementation compares the underlying File references.
|
* This implementation compares the underlying File references.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (obj == this ||
|
return (this == other || (other instanceof FileSystemResource &&
|
||||||
(obj instanceof FileSystemResource && this.path.equals(((FileSystemResource) obj).path)));
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.
|
* This implementation compares the underlying InputStream.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (obj == this ||
|
return (this == other || (other instanceof InputStreamResource &&
|
||||||
(obj instanceof InputStreamResource && ((InputStreamResource) obj).inputStream.equals(this.inputStream)));
|
((InputStreamResource) other).inputStream.equals(this.inputStream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -274,9 +274,9 @@ public class PathResource extends AbstractResource implements WritableResource {
|
||||||
* This implementation compares the underlying Path references.
|
* This implementation compares the underlying Path references.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (this == obj ||
|
return (this == other || (other instanceof PathResource &&
|
||||||
(obj instanceof PathResource && this.path.equals(((PathResource) obj).path)));
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.
|
* This implementation compares the underlying URL references.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (obj == this ||
|
return (this == other || (other instanceof UrlResource &&
|
||||||
(obj instanceof UrlResource && this.cleanedUrl.equals(((UrlResource) obj).cleanedUrl)));
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -125,8 +125,9 @@ public class VfsResource extends AbstractResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (obj == this || (obj instanceof VfsResource && this.resource.equals(((VfsResource) obj).resource)));
|
return (this == other || (other instanceof VfsResource &&
|
||||||
|
this.resource.equals(((VfsResource) other).resource)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -57,22 +57,22 @@ public interface DataBuffer {
|
||||||
DataBufferFactory factory();
|
DataBufferFactory factory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the index of the first byte in this buffer that matches the given
|
* Return the index of the first byte in this buffer that matches
|
||||||
* predicate.
|
* the given predicate.
|
||||||
* @param predicate the predicate to match
|
* @param predicate the predicate to match
|
||||||
* @param fromIndex the index to start the search from
|
* @param fromIndex the index to start the search from
|
||||||
* @return the index of the first byte that matches {@code predicate}; or {@code -1}
|
* @return the index of the first byte that matches {@code predicate};
|
||||||
* if none match
|
* or {@code -1} if none match
|
||||||
*/
|
*/
|
||||||
int indexOf(IntPredicate predicate, int fromIndex);
|
int indexOf(IntPredicate predicate, int fromIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the index of the last byte in this buffer that matches the given
|
* Return the index of the last byte in this buffer that matches
|
||||||
* predicate.
|
* the given predicate.
|
||||||
* @param predicate the predicate to match
|
* @param predicate the predicate to match
|
||||||
* @param fromIndex the index to start the search from
|
* @param fromIndex the index to start the search from
|
||||||
* @return the index of the last byte that matches {@code predicate}; or {@code -1}
|
* @return the index of the last byte that matches {@code predicate};
|
||||||
* if none match
|
* or {@code -1} if none match
|
||||||
*/
|
*/
|
||||||
int lastIndexOf(IntPredicate predicate, int fromIndex);
|
int lastIndexOf(IntPredicate predicate, int fromIndex);
|
||||||
|
|
||||||
|
|
@ -97,9 +97,10 @@ public interface DataBuffer {
|
||||||
int capacity();
|
int capacity();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the number of bytes that this buffer can contain. If the new capacity is lower than
|
* Set the number of bytes that this buffer can contain.
|
||||||
* the current capacity, the contents of this buffer will be truncated. If the new capacity
|
* <p>If the new capacity is lower than the current capacity, the contents
|
||||||
* is higher than the current capacity, it will be expanded.
|
* 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
|
* @param capacity the new capacity
|
||||||
* @return this buffer
|
* @return this buffer
|
||||||
*/
|
*/
|
||||||
|
|
@ -116,8 +117,8 @@ public interface DataBuffer {
|
||||||
* Set the position from which this buffer will read.
|
* Set the position from which this buffer will read.
|
||||||
* @param readPosition the new read position
|
* @param readPosition the new read position
|
||||||
* @return this buffer
|
* @return this buffer
|
||||||
* @throws IndexOutOfBoundsException if {@code readPosition} is smaller than 0 or greater than
|
* @throws IndexOutOfBoundsException if {@code readPosition} is smaller than 0
|
||||||
* {@link #writePosition()}
|
* or greater than {@link #writePosition()}
|
||||||
* @since 5.0.1
|
* @since 5.0.1
|
||||||
*/
|
*/
|
||||||
DataBuffer readPosition(int readPosition);
|
DataBuffer readPosition(int readPosition);
|
||||||
|
|
|
||||||
|
|
@ -27,14 +27,13 @@ import java.util.function.IntPredicate;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation of the {@link DataBuffer} interface that uses a
|
* Default implementation of the {@link DataBuffer} interface that uses a
|
||||||
* {@link ByteBuffer} internally. with separate read and write positions.
|
* {@link ByteBuffer} internally. with separate read and write positions.
|
||||||
* Constructed using the {@link DefaultDataBufferFactory}.
|
* Constructed using the {@link DefaultDataBufferFactory}.
|
||||||
*
|
*
|
||||||
* <p>Inspired by Netty's {@code ByteBuf}. Introduced so that non-Netty runtimes (i.e. Servlet)
|
* <p>Inspired by Netty's {@code ByteBuf}. Introduced so that non-Netty runtimes
|
||||||
* do not require Netty on the classpath.
|
* (i.e. Servlet) do not require Netty on the classpath.
|
||||||
*
|
*
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
|
@ -52,32 +51,29 @@ public class DefaultDataBuffer implements DataBuffer {
|
||||||
|
|
||||||
private ByteBuffer byteBuffer;
|
private ByteBuffer byteBuffer;
|
||||||
|
|
||||||
|
private int capacity;
|
||||||
|
|
||||||
private int readPosition;
|
private int readPosition;
|
||||||
|
|
||||||
private int writePosition;
|
private int writePosition;
|
||||||
|
|
||||||
private int capacity;
|
|
||||||
|
|
||||||
private DefaultDataBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer) {
|
private DefaultDataBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer) {
|
||||||
Assert.notNull(dataBufferFactory, "'dataBufferFactory' must not be null");
|
Assert.notNull(dataBufferFactory, "DefaultDataBufferFactory must not be null");
|
||||||
Assert.notNull(byteBuffer, "'byteBuffer' must not be null");
|
Assert.notNull(byteBuffer, "ByteBuffer must not be null");
|
||||||
|
|
||||||
this.dataBufferFactory = dataBufferFactory;
|
this.dataBufferFactory = dataBufferFactory;
|
||||||
ByteBuffer slice = byteBuffer.slice();
|
ByteBuffer slice = byteBuffer.slice();
|
||||||
this.byteBuffer = slice;
|
this.byteBuffer = slice;
|
||||||
this.capacity = slice.remaining();
|
this.capacity = slice.remaining();
|
||||||
}
|
}
|
||||||
|
|
||||||
static DefaultDataBuffer fromFilledByteBuffer(DefaultDataBufferFactory dataBufferFactory,
|
static DefaultDataBuffer fromFilledByteBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer) {
|
||||||
ByteBuffer byteBuffer) {
|
|
||||||
|
|
||||||
DefaultDataBuffer dataBuffer = new DefaultDataBuffer(dataBufferFactory, byteBuffer);
|
DefaultDataBuffer dataBuffer = new DefaultDataBuffer(dataBufferFactory, byteBuffer);
|
||||||
dataBuffer.writePosition(byteBuffer.remaining());
|
dataBuffer.writePosition(byteBuffer.remaining());
|
||||||
return dataBuffer;
|
return dataBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DefaultDataBuffer fromEmptyByteBuffer(DefaultDataBufferFactory dataBufferFactory,
|
static DefaultDataBuffer fromEmptyByteBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer) {
|
||||||
ByteBuffer byteBuffer) {
|
|
||||||
return new DefaultDataBuffer(dataBufferFactory, byteBuffer);
|
return new DefaultDataBuffer(dataBufferFactory, byteBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,6 +91,7 @@ public class DefaultDataBuffer implements DataBuffer {
|
||||||
this.capacity = byteBuffer.remaining();
|
this.capacity = byteBuffer.remaining();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DefaultDataBufferFactory factory() {
|
public DefaultDataBufferFactory factory() {
|
||||||
return this.dataBufferFactory;
|
return this.dataBufferFactory;
|
||||||
|
|
@ -414,17 +411,17 @@ public class DefaultDataBuffer implements DataBuffer {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof DefaultDataBuffer)) {
|
if (!(other instanceof DefaultDataBuffer)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DefaultDataBuffer other = (DefaultDataBuffer) obj;
|
DefaultDataBuffer otherBuffer = (DefaultDataBuffer) other;
|
||||||
return (this.readPosition == other.readPosition &&
|
return (this.readPosition == otherBuffer.readPosition &&
|
||||||
this.writePosition == other.writePosition &&
|
this.writePosition == otherBuffer.writePosition &&
|
||||||
this.byteBuffer.equals(other.byteBuffer));
|
this.byteBuffer.equals(otherBuffer.byteBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -434,10 +431,11 @@ public class DefaultDataBuffer implements DataBuffer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("DefaultDataBuffer (r: %d, w %d, c %d)", this.readPosition,
|
return String.format("DefaultDataBuffer (r: %d, w %d, c %d)",
|
||||||
this.writePosition, this.capacity);
|
this.readPosition, this.writePosition, this.capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void checkIndex(int index, int length) {
|
private void checkIndex(int index, int length) {
|
||||||
assertIndex(index >= 0, "index %d must be >= 0", index);
|
assertIndex(index >= 0, "index %d must be >= 0", index);
|
||||||
assertIndex(length >= 0, "length %d must be >= 0", index);
|
assertIndex(length >= 0, "length %d must be >= 0", index);
|
||||||
|
|
@ -452,6 +450,7 @@ public class DefaultDataBuffer implements DataBuffer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class DefaultDataBufferInputStream extends InputStream {
|
private class DefaultDataBufferInputStream extends InputStream {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -479,7 +478,6 @@ public class DefaultDataBuffer implements DataBuffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private class DefaultDataBufferOutputStream extends OutputStream {
|
private class DefaultDataBufferOutputStream extends OutputStream {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -496,16 +494,14 @@ public class DefaultDataBuffer implements DataBuffer {
|
||||||
|
|
||||||
private static class SlicedDefaultDataBuffer extends DefaultDataBuffer {
|
private static class SlicedDefaultDataBuffer extends DefaultDataBuffer {
|
||||||
|
|
||||||
SlicedDefaultDataBuffer(ByteBuffer byteBuffer, DefaultDataBufferFactory dataBufferFactory,
|
SlicedDefaultDataBuffer(ByteBuffer byteBuffer, DefaultDataBufferFactory dataBufferFactory, int length) {
|
||||||
int length) {
|
|
||||||
super(dataBufferFactory, byteBuffer);
|
super(dataBufferFactory, byteBuffer);
|
||||||
writePosition(length);
|
writePosition(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DefaultDataBuffer capacity(int newCapacity) {
|
public DefaultDataBuffer capacity(int newCapacity) {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException("Changing the capacity of a sliced buffer is not supported");
|
||||||
"Changing the capacity of a sliced buffer is not supported");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,19 +37,18 @@ import org.springframework.util.Assert;
|
||||||
*/
|
*/
|
||||||
public class NettyDataBuffer implements PooledDataBuffer {
|
public class NettyDataBuffer implements PooledDataBuffer {
|
||||||
|
|
||||||
private final NettyDataBufferFactory dataBufferFactory;
|
|
||||||
|
|
||||||
private final ByteBuf byteBuf;
|
private final ByteBuf byteBuf;
|
||||||
|
|
||||||
|
private final NettyDataBufferFactory dataBufferFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@code NettyDataBuffer} based on the given {@code ByteBuff}.
|
* Creates a new {@code NettyDataBuffer} based on the given {@code ByteBuff}.
|
||||||
* @param byteBuf the buffer to base this buffer on
|
* @param byteBuf the buffer to base this buffer on
|
||||||
*/
|
*/
|
||||||
NettyDataBuffer(ByteBuf byteBuf, NettyDataBufferFactory dataBufferFactory) {
|
NettyDataBuffer(ByteBuf byteBuf, NettyDataBufferFactory dataBufferFactory) {
|
||||||
Assert.notNull(byteBuf, "'byteBuf' must not be null");
|
Assert.notNull(byteBuf, "ByteBuf must not be null");
|
||||||
Assert.notNull(dataBufferFactory, "'dataBufferFactory' must not be null");
|
Assert.notNull(dataBufferFactory, "NettyDataBufferFactory must not be null");
|
||||||
|
|
||||||
this.byteBuf = byteBuf;
|
this.byteBuf = byteBuf;
|
||||||
this.dataBufferFactory = dataBufferFactory;
|
this.dataBufferFactory = dataBufferFactory;
|
||||||
}
|
}
|
||||||
|
|
@ -272,15 +271,9 @@ public class NettyDataBuffer implements PooledDataBuffer {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (this == obj) {
|
return (this == other || (other instanceof NettyDataBuffer &&
|
||||||
return true;
|
this.byteBuf.equals(((NettyDataBuffer) other).byteBuf)));
|
||||||
}
|
|
||||||
if (!(obj instanceof NettyDataBuffer)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
NettyDataBuffer other = (NettyDataBuffer) obj;
|
|
||||||
return this.byteBuf.equals(other.byteBuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -839,12 +839,12 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(@Nullable Object o) {
|
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;
|
Map.Entry<?, ?> entry = (java.util.Map.Entry<?, ?>) o;
|
||||||
Reference<K, V> reference = ConcurrentReferenceHashMap.this.getReference(entry.getKey(), Restructure.NEVER);
|
Reference<K, V> reference = ConcurrentReferenceHashMap.this.getReference(entry.getKey(), Restructure.NEVER);
|
||||||
Entry<K, V> other = (reference != null ? reference.get() : null);
|
Entry<K, V> otherEntry = (reference != null ? reference.get() : null);
|
||||||
if (other != null) {
|
if (otherEntry != null) {
|
||||||
return ObjectUtils.nullSafeEquals(entry.getValue(), other.getValue());
|
return ObjectUtils.nullSafeEquals(otherEntry.getValue(), otherEntry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (this == obj ||
|
return (this == other || (other instanceof BooleanComparator &&
|
||||||
(obj instanceof BooleanComparator && (this.trueLow == ((BooleanComparator) obj).trueLow)));
|
this.trueLow == ((BooleanComparator) other).trueLow));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -187,15 +187,9 @@ public class CompoundComparator<T> implements Comparator<T>, Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (this == obj) {
|
return (this == other || (other instanceof CompoundComparator &&
|
||||||
return true;
|
this.comparators.equals(((CompoundComparator<T>) other).comparators)));
|
||||||
}
|
|
||||||
if (!(obj instanceof CompoundComparator)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
CompoundComparator<T> other = (CompoundComparator<T>) obj;
|
|
||||||
return this.comparators.equals(other.comparators);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -108,15 +108,15 @@ public class InvertibleComparator<T> implements Comparator<T>, Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof InvertibleComparator)) {
|
if (!(other instanceof InvertibleComparator)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
InvertibleComparator<T> other = (InvertibleComparator<T>) obj;
|
InvertibleComparator<T> otherComp = (InvertibleComparator<T>) other;
|
||||||
return (this.comparator.equals(other.comparator) && this.ascending == other.ascending);
|
return (this.comparator.equals(otherComp.comparator) && this.ascending == otherComp.ascending);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -108,15 +108,15 @@ public class NullSafeComparator<T> implements Comparator<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof NullSafeComparator)) {
|
if (!(other instanceof NullSafeComparator)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
NullSafeComparator<T> other = (NullSafeComparator<T>) obj;
|
NullSafeComparator<T> otherComp = (NullSafeComparator<T>) other;
|
||||||
return (this.nonNullComparator.equals(other.nonNullComparator) && this.nullsLow == other.nullsLow);
|
return (this.nonNullComparator.equals(otherComp.nonNullComparator) && this.nullsLow == otherComp.nullsLow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ public class DummyEnvironment implements Environment {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptsProfiles(String... profiles) {
|
public boolean acceptsProfiles(String... profiles) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -117,9 +117,9 @@ public class MessagingMessageConverter implements MessageConverter, Initializing
|
||||||
public Object fromMessage(javax.jms.Message message) throws JMSException, MessageConversionException {
|
public Object fromMessage(javax.jms.Message message) throws JMSException, MessageConversionException {
|
||||||
Map<String, Object> mappedHeaders = extractHeaders(message);
|
Map<String, Object> mappedHeaders = extractHeaders(message);
|
||||||
Object convertedObject = extractPayload(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.fromMessage((org.springframework.messaging.Message<Object>) convertedObject) :
|
||||||
MessageBuilder.withPayload(convertedObject);
|
MessageBuilder.withPayload(convertedObject));
|
||||||
return builder.copyHeadersIfAbsent(mappedHeaders).build();
|
return builder.copyHeadersIfAbsent(mappedHeaders).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,34 +31,18 @@ import org.springframework.lang.Nullable;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
* @param <T> the kind of condition that this condition can be combined with or compared to
|
* @param <T> the kind of condition that this condition can be combined with or compared to
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractMessageCondition<T extends AbstractMessageCondition<T>>
|
public abstract class AbstractMessageCondition<T extends AbstractMessageCondition<T>> implements MessageCondition<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();
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object obj) {
|
public boolean equals(@Nullable Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj != null && getClass() == obj.getClass()) {
|
if (other == null || getClass() != other.getClass()) {
|
||||||
AbstractMessageCondition<?> other = (AbstractMessageCondition<?>) obj;
|
|
||||||
return getContent().equals(other.getContent());
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return getContent().equals(((AbstractMessageCondition<?>) other).getContent());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
@ -79,4 +63,17 @@ public abstract class AbstractMessageCondition<T extends AbstractMessageConditio
|
||||||
return builder.toString();
|
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();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,17 +94,17 @@ public class SimpMessageMappingInfo implements MessageCondition<SimpMessageMappi
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj != null && obj instanceof SimpMessageMappingInfo) {
|
if (!(other instanceof SimpMessageMappingInfo)) {
|
||||||
SimpMessageMappingInfo other = (SimpMessageMappingInfo) obj;
|
|
||||||
return (this.destinationConditions.equals(other.destinationConditions) &&
|
|
||||||
this.messageTypeMessageCondition.equals(other.messageTypeMessageCondition));
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
SimpMessageMappingInfo otherInfo = (SimpMessageMappingInfo) other;
|
||||||
|
return (this.destinationConditions.equals(otherInfo.destinationConditions) &&
|
||||||
|
this.messageTypeMessageCondition.equals(otherInfo.messageTypeMessageCondition));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -44,9 +44,9 @@ public class SpringFlushSynchronization extends TransactionSynchronizationAdapte
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (obj instanceof SpringFlushSynchronization &&
|
return (this == other || (other instanceof SpringFlushSynchronization &&
|
||||||
this.session == ((SpringFlushSynchronization) obj).session);
|
this.session == ((SpringFlushSynchronization) other).session));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -246,10 +246,10 @@ public class SpringContextResourceAdapter implements ResourceAdapter {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (obj instanceof SpringContextResourceAdapter &&
|
return (this == other || (other instanceof SpringContextResourceAdapter &&
|
||||||
ObjectUtils.nullSafeEquals(getContextConfigLocation(),
|
ObjectUtils.nullSafeEquals(getContextConfigLocation(),
|
||||||
((SpringContextResourceAdapter) obj).getContextConfigLocation()));
|
((SpringContextResourceAdapter) other).getContextConfigLocation())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,8 @@ public abstract class DelegatingTransactionDefinition implements TransactionDefi
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return this.targetDefinition.equals(obj);
|
return this.targetDefinition.equals(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -101,9 +101,9 @@ public final class MultipartBodyBuilder {
|
||||||
HttpHeaders partHeaders = new HttpHeaders();
|
HttpHeaders partHeaders = new HttpHeaders();
|
||||||
|
|
||||||
if (part instanceof HttpEntity) {
|
if (part instanceof HttpEntity) {
|
||||||
HttpEntity<?> other = (HttpEntity<?>) part;
|
HttpEntity<?> httpEntity = (HttpEntity<?>) part;
|
||||||
partBody = other.getBody();
|
partBody = httpEntity.getBody();
|
||||||
partHeaders.addAll(other.getHeaders());
|
partHeaders.addAll(httpEntity.getHeaders());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
partBody = part;
|
partBody = part;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package org.springframework.http.codec;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -50,8 +51,6 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.MimeTypeUtils;
|
import org.springframework.util.MimeTypeUtils;
|
||||||
|
|
||||||
import static java.util.Collections.emptyMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code HttpMessageWriter} that can write a {@link Resource}.
|
* {@code HttpMessageWriter} that can write a {@link Resource}.
|
||||||
*
|
*
|
||||||
|
|
@ -244,7 +243,7 @@ public class ResourceHttpMessageWriter implements HttpMessageWriter<Resource> {
|
||||||
.orElseGet(() -> {
|
.orElseGet(() -> {
|
||||||
Publisher<? extends ResourceRegion> input = Mono.just(region);
|
Publisher<? extends ResourceRegion> input = Mono.just(region);
|
||||||
MediaType mediaType = message.getHeaders().getContentType();
|
MediaType mediaType = message.getHeaders().getContentType();
|
||||||
return encodeAndWriteRegions(input, mediaType, message, emptyMap());
|
return encodeAndWriteRegions(input, mediaType, message, Collections.emptyMap());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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()) {
|
if (other == null || getClass() != other.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DefaultRequestPath that = (DefaultRequestPath) other;
|
DefaultRequestPath otherPath= (DefaultRequestPath) other;
|
||||||
return (this.fullPath.equals(that.fullPath) &&
|
return (this.fullPath.equals(otherPath.fullPath) &&
|
||||||
this.contextPath.equals(that.contextPath) &&
|
this.contextPath.equals(otherPath.contextPath) &&
|
||||||
this.pathWithinApplication.equals(that.pathWithinApplication));
|
this.pathWithinApplication.equals(otherPath.pathWithinApplication));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -236,16 +236,16 @@ public class ServletContextResource extends AbstractFileResolvingResource implem
|
||||||
* This implementation compares the underlying ServletContext resource locations.
|
* This implementation compares the underlying ServletContext resource locations.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (obj == this) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj instanceof ServletContextResource) {
|
if (!(other instanceof ServletContextResource)) {
|
||||||
ServletContextResource otherRes = (ServletContextResource) obj;
|
|
||||||
return (this.servletContext.equals(otherRes.servletContext) && this.path.equals(otherRes.path));
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
ServletContextResource otherRes = (ServletContextResource) other;
|
||||||
|
return (this.servletContext.equals(otherRes.servletContext) && this.path.equals(otherRes.path));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This implementation returns the hash code of the underlying
|
* This implementation returns the hash code of the underlying
|
||||||
|
|
|
||||||
|
|
@ -86,9 +86,9 @@ class MultipartFileResource extends AbstractResource {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (obj == this || (obj instanceof MultipartFileResource &&
|
return (this == other || (other instanceof MultipartFileResource &&
|
||||||
((MultipartFileResource) obj).multipartFile.equals(this.multipartFile)));
|
((MultipartFileResource) other).multipartFile.equals(this.multipartFile)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ final class HierarchicalUriComponents extends UriComponents {
|
||||||
|
|
||||||
private static final String PATH_DELIMITER_STRING = "/";
|
private static final String PATH_DELIMITER_STRING = "/";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an empty path.
|
* Represents an empty path.
|
||||||
*/
|
*/
|
||||||
|
|
@ -87,8 +88,8 @@ final class HierarchicalUriComponents extends UriComponents {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (this == obj);
|
return (this == other);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -506,21 +507,21 @@ final class HierarchicalUriComponents extends UriComponents {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof HierarchicalUriComponents)) {
|
if (!(other instanceof HierarchicalUriComponents)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
HierarchicalUriComponents other = (HierarchicalUriComponents) obj;
|
HierarchicalUriComponents otherComp = (HierarchicalUriComponents) other;
|
||||||
return ObjectUtils.nullSafeEquals(getScheme(), other.getScheme()) &&
|
return (ObjectUtils.nullSafeEquals(getScheme(), otherComp.getScheme()) &&
|
||||||
ObjectUtils.nullSafeEquals(getUserInfo(), other.getUserInfo()) &&
|
ObjectUtils.nullSafeEquals(getUserInfo(), otherComp.getUserInfo()) &&
|
||||||
ObjectUtils.nullSafeEquals(getHost(), other.getHost()) &&
|
ObjectUtils.nullSafeEquals(getHost(), otherComp.getHost()) &&
|
||||||
getPort() == other.getPort() &&
|
getPort() == otherComp.getPort() &&
|
||||||
this.path.equals(other.path) &&
|
this.path.equals(otherComp.path) &&
|
||||||
this.queryParams.equals(other.queryParams) &&
|
this.queryParams.equals(otherComp.queryParams) &&
|
||||||
ObjectUtils.nullSafeEquals(getFragment(), other.getFragment());
|
ObjectUtils.nullSafeEquals(getFragment(), otherComp.getFragment()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -752,9 +753,9 @@ final class HierarchicalUriComponents extends UriComponents {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (this == obj || (obj instanceof FullPathComponent &&
|
return (this == other || (other instanceof FullPathComponent &&
|
||||||
getPath().equals(((FullPathComponent) obj).getPath())));
|
getPath().equals(((FullPathComponent) other).getPath())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -830,9 +831,9 @@ final class HierarchicalUriComponents extends UriComponents {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
return (this == obj || (obj instanceof PathSegmentComponent &&
|
return (this == other || (other instanceof PathSegmentComponent &&
|
||||||
getPathSegments().equals(((PathSegmentComponent) obj).getPathSegments())));
|
getPathSegments().equals(((PathSegmentComponent) other).getPathSegments())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -157,19 +157,17 @@ final class OpaqueUriComponents extends UriComponents {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof OpaqueUriComponents)) {
|
if (!(other instanceof OpaqueUriComponents)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
OpaqueUriComponents otherComp = (OpaqueUriComponents) other;
|
||||||
OpaqueUriComponents other = (OpaqueUriComponents) obj;
|
return (ObjectUtils.nullSafeEquals(getScheme(), otherComp.getScheme()) &&
|
||||||
return ObjectUtils.nullSafeEquals(getScheme(), other.getScheme()) &&
|
ObjectUtils.nullSafeEquals(this.ssp, otherComp.ssp) &&
|
||||||
ObjectUtils.nullSafeEquals(this.ssp, other.ssp) &&
|
ObjectUtils.nullSafeEquals(getFragment(), otherComp.getFragment()));
|
||||||
ObjectUtils.nullSafeEquals(getFragment(), other.getFragment());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -209,17 +209,17 @@ public class ResolvableMethod {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatMethod() {
|
private String formatMethod() {
|
||||||
return this.method().getName() +
|
return (this.method().getName() +
|
||||||
Arrays.stream(this.method.getParameters())
|
Arrays.stream(this.method.getParameters())
|
||||||
.map(this::formatParameter)
|
.map(this::formatParameter)
|
||||||
.collect(joining(",\n\t", "(\n\t", "\n)"));
|
.collect(joining(",\n\t", "(\n\t", "\n)")));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatParameter(Parameter param) {
|
private String formatParameter(Parameter param) {
|
||||||
Annotation[] annot = param.getAnnotations();
|
Annotation[] anns = param.getAnnotations();
|
||||||
return annot.length > 0 ?
|
return (anns.length > 0 ?
|
||||||
Arrays.stream(annot).map(this::formatAnnotation).collect(joining(",", "[", "]")) + " " + param :
|
Arrays.stream(anns).map(this::formatAnnotation).collect(joining(",", "[", "]")) + " " + param :
|
||||||
param.toString();
|
param.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatAnnotation(Annotation annotation) {
|
private String formatAnnotation(Annotation annotation) {
|
||||||
|
|
@ -536,9 +536,9 @@ public class ResolvableMethod {
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final ArgResolver annotNotPresent(Class<? extends Annotation>... annotationTypes) {
|
public final ArgResolver annotNotPresent(Class<? extends Annotation>... annotationTypes) {
|
||||||
this.filters.add(param ->
|
this.filters.add(param ->
|
||||||
(annotationTypes.length != 0) ?
|
(annotationTypes.length > 0 ?
|
||||||
Arrays.stream(annotationTypes).noneMatch(param::hasParameterAnnotation) :
|
Arrays.stream(annotationTypes).noneMatch(param::hasParameterAnnotation) :
|
||||||
param.getParameterAnnotations().length == 0);
|
param.getParameterAnnotations().length == 0));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.web.reactive.accept;
|
package org.springframework.web.reactive.accept;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -36,7 +37,7 @@ public class HeaderContentTypeResolver implements RequestedContentTypeResolver {
|
||||||
try {
|
try {
|
||||||
List<MediaType> mediaTypes = exchange.getRequest().getHeaders().getAccept();
|
List<MediaType> mediaTypes = exchange.getRequest().getHeaders().getAccept();
|
||||||
MediaType.sortBySpecificityAndQuality(mediaTypes);
|
MediaType.sortBySpecificityAndQuality(mediaTypes);
|
||||||
return !CollectionUtils.isEmpty(mediaTypes) ? mediaTypes : MEDIA_TYPE_ALL_LIST;
|
return (!CollectionUtils.isEmpty(mediaTypes) ? mediaTypes : MEDIA_TYPE_ALL_LIST);
|
||||||
}
|
}
|
||||||
catch (InvalidMediaTypeException ex) {
|
catch (InvalidMediaTypeException ex) {
|
||||||
String value = exchange.getRequest().getHeaders().getFirst("Accept");
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.
|
* of resolvers configured through this builder.
|
||||||
*/
|
*/
|
||||||
public RequestedContentTypeResolver build() {
|
public RequestedContentTypeResolver build() {
|
||||||
|
List<RequestedContentTypeResolver> resolvers = (!this.candidates.isEmpty() ?
|
||||||
List<RequestedContentTypeResolver> resolvers =
|
this.candidates.stream().map(Supplier::get).collect(Collectors.toList()) :
|
||||||
this.candidates.isEmpty() ?
|
Collections.singletonList(new HeaderContentTypeResolver()));
|
||||||
Collections.singletonList(new HeaderContentTypeResolver()) :
|
|
||||||
this.candidates.stream().map(Supplier::get).collect(Collectors.toList());
|
|
||||||
|
|
||||||
return exchange -> {
|
return exchange -> {
|
||||||
for (RequestedContentTypeResolver resolver : resolvers) {
|
for (RequestedContentTypeResolver resolver : resolvers) {
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,9 @@ public class PathMatchConfigurer {
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
public PathMatchConfigurer addPathPrefix(String prefix, Predicate<Class<?>> predicate) {
|
public PathMatchConfigurer addPathPrefix(String prefix, Predicate<Class<?>> predicate) {
|
||||||
this.pathPrefixes = this.pathPrefixes == null ? new LinkedHashMap<>() : this.pathPrefixes;
|
if (this.pathPrefixes == null) {
|
||||||
|
this.pathPrefixes = new LinkedHashMap<>();
|
||||||
|
}
|
||||||
this.pathPrefixes.put(prefix, predicate);
|
this.pathPrefixes.put(prefix, predicate);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,6 @@ class DefaultWebClient implements WebClient {
|
||||||
|
|
||||||
private final Map<String, Object> attributes = new LinkedHashMap<>(4);
|
private final Map<String, Object> attributes = new LinkedHashMap<>(4);
|
||||||
|
|
||||||
|
|
||||||
DefaultRequestBodyUriSpec(HttpMethod httpMethod) {
|
DefaultRequestBodyUriSpec(HttpMethod httpMethod) {
|
||||||
this.httpMethod = httpMethod;
|
this.httpMethod = httpMethod;
|
||||||
}
|
}
|
||||||
|
|
@ -318,7 +317,7 @@ class DefaultWebClient implements WebClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClientRequest.Builder initRequestBuilder() {
|
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)
|
return ClientRequest.create(this.httpMethod, uri)
|
||||||
.headers(headers -> headers.addAll(initHeaders()))
|
.headers(headers -> headers.addAll(initHeaders()))
|
||||||
.cookies(cookies -> cookies.addAll(initCookies()))
|
.cookies(cookies -> cookies.addAll(initCookies()))
|
||||||
|
|
|
||||||
|
|
@ -228,9 +228,8 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
|
||||||
if (this.uriBuilderFactory != null) {
|
if (this.uriBuilderFactory != null) {
|
||||||
return this.uriBuilderFactory;
|
return this.uriBuilderFactory;
|
||||||
}
|
}
|
||||||
DefaultUriBuilderFactory factory = this.baseUrl != null ?
|
DefaultUriBuilderFactory factory = (this.baseUrl != null ?
|
||||||
new DefaultUriBuilderFactory(this.baseUrl) : new DefaultUriBuilderFactory();
|
new DefaultUriBuilderFactory(this.baseUrl) : new DefaultUriBuilderFactory());
|
||||||
|
|
||||||
factory.setDefaultUriVariables(this.defaultUriVariables);
|
factory.setDefaultUriVariables(this.defaultUriVariables);
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,10 +92,8 @@ public abstract class ExchangeFilterFunctions {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkIllegalCharacters(String username, String password) {
|
private static void checkIllegalCharacters(String username, String password) {
|
||||||
|
|
||||||
// Basic authentication only supports ISO 8859-1, see
|
// Basic authentication only supports ISO 8859-1, see
|
||||||
// https://stackoverflow.com/questions/702629/utf-8-characters-mangled-in-http-basic-auth-username#703341
|
// https://stackoverflow.com/questions/702629/utf-8-characters-mangled-in-http-basic-auth-username#703341
|
||||||
|
|
||||||
CharsetEncoder encoder = StandardCharsets.ISO_8859_1.newEncoder();
|
CharsetEncoder encoder = StandardCharsets.ISO_8859_1.newEncoder();
|
||||||
if (!encoder.canEncode(username) || !encoder.canEncode(password)) {
|
if (!encoder.canEncode(username) || !encoder.canEncode(password)) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
|
@ -113,7 +111,6 @@ public abstract class ExchangeFilterFunctions {
|
||||||
}).build();
|
}).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a filter that generates an error signal when the given
|
* Return a filter that generates an error signal when the given
|
||||||
* {@link HttpStatus} predicate matches.
|
* {@link HttpStatus} predicate matches.
|
||||||
|
|
@ -128,10 +125,8 @@ public abstract class ExchangeFilterFunctions {
|
||||||
Assert.notNull(exceptionFunction, "Function must not be null");
|
Assert.notNull(exceptionFunction, "Function must not be null");
|
||||||
|
|
||||||
return ExchangeFilterFunction.ofResponseProcessor(
|
return ExchangeFilterFunction.ofResponseProcessor(
|
||||||
response -> statusPredicate.test(response.statusCode()) ?
|
response -> (statusPredicate.test(response.statusCode()) ?
|
||||||
Mono.error(exceptionFunction.apply(response)) :
|
Mono.error(exceptionFunction.apply(response)) : Mono.just(response)));
|
||||||
Mono.just(response)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -146,7 +141,6 @@ public abstract class ExchangeFilterFunctions {
|
||||||
|
|
||||||
private final String password;
|
private final String password;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@code Credentials} instance with the given username and password.
|
* Create a new {@code Credentials} instance with the given username and password.
|
||||||
* @param username the username
|
* @param username the username
|
||||||
|
|
@ -159,7 +153,6 @@ public abstract class ExchangeFilterFunctions {
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@literal Consumer} that stores the given user and password
|
* Return a {@literal Consumer} that stores the given user and password
|
||||||
* as a request attribute of type {@code Credentials} that is in turn
|
* as a request attribute of type {@code Credentials} that is in turn
|
||||||
|
|
@ -174,22 +167,20 @@ public abstract class ExchangeFilterFunctions {
|
||||||
public static Consumer<Map<String, Object>> basicAuthenticationCredentials(String user, String password) {
|
public static Consumer<Map<String, Object>> basicAuthenticationCredentials(String user, String password) {
|
||||||
Credentials credentials = new Credentials(user, password);
|
Credentials credentials = new Credentials(user, password);
|
||||||
checkIllegalCharacters(user, password);
|
checkIllegalCharacters(user, password);
|
||||||
return map -> map.put(BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE, credentials);
|
return (map -> map.put(BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE, credentials));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object other) {
|
||||||
if (this == o) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (o instanceof Credentials) {
|
if (!(other instanceof Credentials)) {
|
||||||
Credentials other = (Credentials) o;
|
|
||||||
return this.username.equals(other.username) &&
|
|
||||||
this.password.equals(other.password);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Credentials otherCred = (Credentials) other;
|
||||||
|
return (this.username.equals(otherCred.username) && this.password.equals(otherCred.password));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,6 @@ public abstract class ExchangeFunctions {
|
||||||
@Override
|
@Override
|
||||||
public Mono<ClientResponse> exchange(ClientRequest request) {
|
public Mono<ClientResponse> exchange(ClientRequest request) {
|
||||||
Assert.notNull(request, "ClientRequest must not be null");
|
Assert.notNull(request, "ClientRequest must not be null");
|
||||||
|
|
||||||
HttpMethod httpMethod = request.method();
|
HttpMethod httpMethod = request.method();
|
||||||
URI url = request.url();
|
URI url = request.url();
|
||||||
|
|
||||||
|
|
@ -112,7 +111,7 @@ public abstract class ExchangeFunctions {
|
||||||
String formatted = request.url().toString();
|
String formatted = request.url().toString();
|
||||||
if (this.disableLoggingRequestDetails) {
|
if (this.disableLoggingRequestDetails) {
|
||||||
int index = formatted.indexOf("?");
|
int index = formatted.indexOf("?");
|
||||||
formatted = index != -1 ? formatted.substring(0, index) : formatted;
|
formatted = (index != -1 ? formatted.substring(0, index) : formatted);
|
||||||
}
|
}
|
||||||
logger.debug("HTTP " + request.method() + " " + formatted);
|
logger.debug("HTTP " + request.method() + " " + formatted);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
|
||||||
value = UriUtils.decode(value, StandardCharsets.UTF_8);
|
value = UriUtils.decode(value, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
value = StringUtils.hasLength(eq) ? "" : null;
|
value = (StringUtils.hasLength(eq) ? "" : null);
|
||||||
}
|
}
|
||||||
queryParams.add(name, value);
|
queryParams.add(name, value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ import org.springframework.web.server.ServerWebExchange;
|
||||||
/**
|
/**
|
||||||
* {@code HandlerMapping} implementation that supports {@link RouterFunction RouterFunctions}.
|
* {@code HandlerMapping} implementation that supports {@link RouterFunction RouterFunctions}.
|
||||||
* <p>If no {@link RouterFunction} is provided at
|
* <p>If no {@link RouterFunction} is provided at
|
||||||
* {@linkplain #RouterFunctionMapping(RouterFunction) construction time}, this mapping will detect
|
* {@linkplain #RouterFunctionMapping(RouterFunction) construction time}, this mapping
|
||||||
* all router functions in the application context, and consult them in
|
* will detect all router functions in the application context, and consult them in
|
||||||
* {@linkplain org.springframework.core.annotation.Order order}.
|
* {@linkplain org.springframework.core.annotation.Order order}.
|
||||||
*
|
*
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
|
|
@ -114,7 +114,7 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
|
||||||
SortedRouterFunctionsContainer container = new SortedRouterFunctionsContainer();
|
SortedRouterFunctionsContainer container = new SortedRouterFunctionsContainer();
|
||||||
obtainApplicationContext().getAutowireCapableBeanFactory().autowireBean(container);
|
obtainApplicationContext().getAutowireCapableBeanFactory().autowireBean(container);
|
||||||
List<RouterFunction<?>> functions = container.routerFunctions;
|
List<RouterFunction<?>> functions = container.routerFunctions;
|
||||||
return CollectionUtils.isEmpty(functions) ? Collections.emptyList() : functions;
|
return (!CollectionUtils.isEmpty(functions) ? functions : Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logRouterFunctions(List<RouterFunction<?>> routerFunctions) {
|
private void logRouterFunctions(List<RouterFunction<?>> routerFunctions) {
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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) {
|
protected AbstractPrefixVersionStrategy(String version) {
|
||||||
Assert.hasText(version, "'version' must not be empty");
|
Assert.hasText(version, "Version must not be empty");
|
||||||
this.prefix = version;
|
this.prefix = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String extractVersion(String requestPath) {
|
public String extractVersion(String requestPath) {
|
||||||
return requestPath.startsWith(this.prefix) ? this.prefix : null;
|
return (requestPath.startsWith(this.prefix) ? this.prefix : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -82,18 +82,15 @@ public class CachingResourceResolver extends AbstractResourceResolver {
|
||||||
/**
|
/**
|
||||||
* Configure the supported content codings from the
|
* Configure the supported content codings from the
|
||||||
* {@literal "Accept-Encoding"} header for which to cache resource variations.
|
* {@literal "Accept-Encoding"} header for which to cache resource variations.
|
||||||
*
|
|
||||||
* <p>The codings configured here are generally expected to match those
|
* <p>The codings configured here are generally expected to match those
|
||||||
* configured on {@link EncodedResourceResolver#setContentCodings(List)}.
|
* configured on {@link EncodedResourceResolver#setContentCodings(List)}.
|
||||||
*
|
|
||||||
* <p>By default this property is set to {@literal ["br", "gzip"]} based on
|
* <p>By default this property is set to {@literal ["br", "gzip"]} based on
|
||||||
* the value of {@link EncodedResourceResolver#DEFAULT_CODINGS}.
|
* the value of {@link EncodedResourceResolver#DEFAULT_CODINGS}.
|
||||||
*
|
|
||||||
* @param codings one or more supported content codings
|
* @param codings one or more supported content codings
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
public void setContentCodings(List<String> codings) {
|
public void setContentCodings(List<String> codings) {
|
||||||
Assert.notEmpty(codings, "At least one content coding expected.");
|
Assert.notEmpty(codings, "At least one content coding expected");
|
||||||
this.contentCodings.clear();
|
this.contentCodings.clear();
|
||||||
this.contentCodings.addAll(codings);
|
this.contentCodings.addAll(codings);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ import org.springframework.core.io.Resource;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.StreamUtils;
|
import org.springframework.util.StreamUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
|
|
@ -281,20 +280,20 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(ContentChunkInfo other) {
|
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
|
@Override
|
||||||
public boolean equals(@Nullable Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj != null && obj instanceof ContentChunkInfo) {
|
if (!(other instanceof ContentChunkInfo)) {
|
||||||
ContentChunkInfo other = (ContentChunkInfo) obj;
|
|
||||||
return (this.start == other.start && this.end == other.end);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
ContentChunkInfo otherCci = (ContentChunkInfo) other;
|
||||||
|
return (this.start == otherCci.start && this.end == otherCci.end);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
|
||||||
|
|
@ -78,27 +78,22 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
|
||||||
* coding that is present in the {@literal "Accept-Encoding"} header for a
|
* coding that is present in the {@literal "Accept-Encoding"} header for a
|
||||||
* given request, and that has a file present with the associated extension,
|
* given request, and that has a file present with the associated extension,
|
||||||
* is used.
|
* is used.
|
||||||
*
|
|
||||||
* <p><strong>Note:</strong> Each coding must be associated with a file
|
* <p><strong>Note:</strong> Each coding must be associated with a file
|
||||||
* extension via {@link #registerExtension} or {@link #setExtensions}. Also
|
* extension via {@link #registerExtension} or {@link #setExtensions}. Also
|
||||||
* customizations to the list of codings here should be matched by
|
* customizations to the list of codings here should be matched by
|
||||||
* customizations to the same list in {@link CachingResourceResolver} to
|
* customizations to the same list in {@link CachingResourceResolver} to
|
||||||
* ensure encoded variants of a resource are cached under separate keys.
|
* ensure encoded variants of a resource are cached under separate keys.
|
||||||
*
|
|
||||||
* <p>By default this property is set to {@literal ["br", "gzip"]}.
|
* <p>By default this property is set to {@literal ["br", "gzip"]}.
|
||||||
*
|
|
||||||
* @param codings one or more supported content codings
|
* @param codings one or more supported content codings
|
||||||
* @since 5.1
|
|
||||||
*/
|
*/
|
||||||
public void setContentCodings(List<String> codings) {
|
public void setContentCodings(List<String> codings) {
|
||||||
Assert.notEmpty(codings, "At least one content coding expected.");
|
Assert.notEmpty(codings, "At least one content coding expected");
|
||||||
this.contentCodings.clear();
|
this.contentCodings.clear();
|
||||||
this.contentCodings.addAll(codings);
|
this.contentCodings.addAll(codings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a read-only list with the supported content codings.
|
* Return a read-only list with the supported content codings.
|
||||||
* @since 5.1
|
|
||||||
*/
|
*/
|
||||||
public List<String> getContentCodings() {
|
public List<String> getContentCodings() {
|
||||||
return Collections.unmodifiableList(this.contentCodings);
|
return Collections.unmodifiableList(this.contentCodings);
|
||||||
|
|
@ -110,31 +105,28 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
|
||||||
* <p>By default this is configured with {@literal ["br" -> ".br"]} and
|
* <p>By default this is configured with {@literal ["br" -> ".br"]} and
|
||||||
* {@literal ["gzip" -> ".gz"]}.
|
* {@literal ["gzip" -> ".gz"]}.
|
||||||
* @param extensions the extensions to use.
|
* @param extensions the extensions to use.
|
||||||
* @since 5.1
|
|
||||||
* @see #registerExtension(String, String)
|
* @see #registerExtension(String, String)
|
||||||
*/
|
*/
|
||||||
public void setExtensions(Map<String, String> extensions) {
|
public void setExtensions(Map<String, String> extensions) {
|
||||||
extensions.forEach(this::registerExtension);
|
extensions.forEach(this::registerExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Java config friendly alternative to {@link #setExtensions(Map)}.
|
|
||||||
* @param coding the content coding
|
|
||||||
* @param extension the associated file extension
|
|
||||||
* @since 5.1
|
|
||||||
*/
|
|
||||||
public void registerExtension(String coding, String extension) {
|
|
||||||
this.extensions.put(coding, extension.startsWith(".") ? extension : "." + extension);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a read-only map with coding-to-extension mappings.
|
* Return a read-only map with coding-to-extension mappings.
|
||||||
* @since 5.1
|
|
||||||
*/
|
*/
|
||||||
public Map<String, String> getExtensions() {
|
public Map<String, String> getExtensions() {
|
||||||
return Collections.unmodifiableMap(this.extensions);
|
return Collections.unmodifiableMap(this.extensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Java config friendly alternative to {@link #setExtensions(Map)}.
|
||||||
|
* @param coding the content coding
|
||||||
|
* @param extension the associated file extension
|
||||||
|
*/
|
||||||
|
public void registerExtension(String coding, String extension) {
|
||||||
|
this.extensions.put(coding, (extension.startsWith(".") ? extension : "." + extension));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Mono<Resource> resolveResourceInternal(@Nullable ServerWebExchange exchange,
|
protected Mono<Resource> resolveResourceInternal(@Nullable ServerWebExchange exchange,
|
||||||
|
|
@ -174,12 +166,12 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
|
||||||
private String getAcceptEncoding(ServerWebExchange exchange) {
|
private String getAcceptEncoding(ServerWebExchange exchange) {
|
||||||
ServerHttpRequest request = exchange.getRequest();
|
ServerHttpRequest request = exchange.getRequest();
|
||||||
String header = request.getHeaders().getFirst(HttpHeaders.ACCEPT_ENCODING);
|
String header = request.getHeaders().getFirst(HttpHeaders.ACCEPT_ENCODING);
|
||||||
return header != null ? header.toLowerCase() : null;
|
return (header != null ? header.toLowerCase() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getExtension(String coding) {
|
private String getExtension(String coding) {
|
||||||
String extension = this.extensions.get(coding);
|
String extension = this.extensions.get(coding);
|
||||||
Assert.notNull(extension, "No file extension associated with content coding " + coding);
|
Assert.state(extension != null, () -> "No file extension associated with content coding " + coding);
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -202,7 +194,6 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
|
||||||
|
|
||||||
private final Resource encoded;
|
private final Resource encoded;
|
||||||
|
|
||||||
|
|
||||||
EncodedResource(Resource original, String coding, String extension) throws IOException {
|
EncodedResource(Resource original, String coding, String extension) throws IOException {
|
||||||
this.original = original;
|
this.original = original;
|
||||||
this.coding = coding;
|
this.coding = coding;
|
||||||
|
|
|
||||||
|
|
@ -388,8 +388,8 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||||
return Mono.empty();
|
return Mono.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.notNull(this.resolverChain, "ResourceResolverChain not initialized.");
|
Assert.state(this.resolverChain != null, "ResourceResolverChain not initialized");
|
||||||
Assert.notNull(this.transformerChain, "ResourceTransformerChain not initialized.");
|
Assert.state(this.transformerChain != null, "ResourceTransformerChain not initialized");
|
||||||
|
|
||||||
return this.resolverChain.resolveResource(exchange, path, getLocations())
|
return this.resolverChain.resolveResource(exchange, path, getLocations())
|
||||||
.flatMap(resource -> this.transformerChain.transform(exchange, resource));
|
.flatMap(resource -> this.transformerChain.transform(exchange, resource));
|
||||||
|
|
@ -419,7 +419,7 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||||
for (int i = 0; i < path.length(); i++) {
|
for (int i = 0; i < path.length(); i++) {
|
||||||
char curr = path.charAt(i);
|
char curr = path.charAt(i);
|
||||||
try {
|
try {
|
||||||
if ((curr == '/') && (prev == '/')) {
|
if (curr == '/' && prev == '/') {
|
||||||
if (sb == null) {
|
if (sb == null) {
|
||||||
sb = new StringBuilder(path.substring(0, i));
|
sb = new StringBuilder(path.substring(0, i));
|
||||||
}
|
}
|
||||||
|
|
@ -433,7 +433,7 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||||
prev = curr;
|
prev = curr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb != null ? sb.toString() : path;
|
return (sb != null ? sb.toString() : path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String cleanLeadingSlash(String path) {
|
private String cleanLeadingSlash(String path) {
|
||||||
|
|
@ -446,7 +446,7 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||||
if (i == 0 || (i == 1 && slash)) {
|
if (i == 0 || (i == 1 && slash)) {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
return slash ? "/" + path.substring(i) : path.substring(i);
|
return (slash ? "/" + path.substring(i) : path.substring(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (slash ? "/" : "");
|
return (slash ? "/" : "");
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.server.NotAcceptableStatusException;
|
import org.springframework.web.server.NotAcceptableStatusException;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
|
|
@ -89,16 +90,16 @@ abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTy
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(@Nullable Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj != null && getClass() == obj.getClass()) {
|
if (other == null || getClass() != other.getClass()) {
|
||||||
AbstractMediaTypeExpression other = (AbstractMediaTypeExpression) obj;
|
|
||||||
return (this.mediaType.equals(other.mediaType) && this.isNegated == other.isNegated);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
AbstractMediaTypeExpression otherExpr = (AbstractMediaTypeExpression) other;
|
||||||
|
return (this.mediaType.equals(otherExpr.mediaType) && this.isNegated == otherExpr.isNegated);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
|
||||||
|
|
@ -92,20 +92,17 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(@Nullable Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj != null && obj instanceof AbstractNameValueExpression) {
|
if (other == null || getClass() != other.getClass()) {
|
||||||
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);
|
|
||||||
}
|
|
||||||
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
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
@ -134,4 +131,5 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ package org.springframework.web.reactive.result.condition;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A base class for {@link RequestCondition} types providing implementations of
|
* A base class for {@link RequestCondition} types providing implementations of
|
||||||
* {@link #equals(Object)}, {@link #hashCode()}, and {@link #toString()}.
|
* {@link #equals(Object)}, {@link #hashCode()}, and {@link #toString()}.
|
||||||
|
|
@ -28,20 +30,18 @@ import java.util.Iterator;
|
||||||
* @param <T> the type of objects that this RequestCondition can be combined
|
* @param <T> the type of objects that this RequestCondition can be combined
|
||||||
* with and compared to
|
* with and compared to
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractRequestCondition<T extends AbstractRequestCondition<T>>
|
public abstract class AbstractRequestCondition<T extends AbstractRequestCondition<T>> implements RequestCondition<T> {
|
||||||
implements RequestCondition<T> {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(@Nullable Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj != null && getClass() == obj.getClass()) {
|
if (other == null || getClass() != other.getClass()) {
|
||||||
AbstractRequestCondition<?> other = (AbstractRequestCondition<?>) obj;
|
|
||||||
return getContent().equals(other.getContent());
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return getContent().equals(((AbstractRequestCondition<?>) other).getContent());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
@Override
|
||||||
protected Collection<?> getContent() {
|
protected Collection<?> getContent() {
|
||||||
return (isEmpty()) ? Collections.emptyList() : getConditions();
|
return (!isEmpty() ? getConditions() : Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition<Con
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ConsumesRequestCondition combine(ConsumesRequestCondition other) {
|
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<>(this.expressions);
|
Set<ConsumeMediaTypeExpression> result = new LinkedHashSet<>(this.expressions);
|
||||||
result.removeIf(expression -> !expression.match(exchange));
|
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.
|
* Creates a new instance with the given {@code Stream} of URL patterns.
|
||||||
*/
|
*/
|
||||||
public PatternsRequestCondition(List<PathPattern> 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) {
|
private PatternsRequestCondition(SortedSet<PathPattern> patterns) {
|
||||||
this.patterns = patterns;
|
this.patterns = patterns;
|
||||||
|
|
@ -127,8 +122,7 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
SortedSet<PathPattern> matches = getMatchingPatterns(exchange);
|
SortedSet<PathPattern> matches = getMatchingPatterns(exchange);
|
||||||
return matches.isEmpty() ? null :
|
return (!matches.isEmpty() ? new PatternsRequestCondition(matches) : null);
|
||||||
new PatternsRequestCondition(matches);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
|
||||||
}
|
}
|
||||||
Set<ProduceMediaTypeExpression> result = new LinkedHashSet<>(this.expressions);
|
Set<ProduceMediaTypeExpression> result = new LinkedHashSet<>(this.expressions);
|
||||||
result.removeIf(expression -> !expression.match(exchange));
|
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 expr1 = condition1.getExpressionsToCompare().get(index1);
|
||||||
ProduceMediaTypeExpression expr2 = condition2.getExpressionsToCompare().get(index2);
|
ProduceMediaTypeExpression expr2 = condition2.getExpressionsToCompare().get(index2);
|
||||||
result = expr1.compareTo(expr2);
|
result = expr1.compareTo(expr2);
|
||||||
result = (result != 0) ? result : expr1.getMediaType().compareTo(expr2.getMediaType());
|
result = (result != 0 ? result : expr1.getMediaType().compareTo(expr2.getMediaType()));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,8 +130,8 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||||
* @param providedArgs optional list of argument values to match by type
|
* @param providedArgs optional list of argument values to match by type
|
||||||
* @return a Mono with a {@link HandlerResult}.
|
* @return a Mono with a {@link HandlerResult}.
|
||||||
*/
|
*/
|
||||||
public Mono<HandlerResult> invoke(ServerWebExchange exchange, BindingContext bindingContext,
|
public Mono<HandlerResult> invoke(
|
||||||
Object... providedArgs) {
|
ServerWebExchange exchange, BindingContext bindingContext, Object... providedArgs) {
|
||||||
|
|
||||||
return resolveArguments(exchange, bindingContext, providedArgs).flatMap(args -> {
|
return resolveArguments(exchange, bindingContext, providedArgs).flatMap(args -> {
|
||||||
Object value;
|
Object value;
|
||||||
|
|
@ -161,7 +161,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||||
ReactiveAdapter adapter = this.reactiveAdapterRegistry.getAdapter(returnType.getParameterType());
|
ReactiveAdapter adapter = this.reactiveAdapterRegistry.getAdapter(returnType.getParameterType());
|
||||||
boolean asyncVoid = isAsyncVoidReturnType(returnType, adapter);
|
boolean asyncVoid = isAsyncVoidReturnType(returnType, adapter);
|
||||||
if ((value == null || asyncVoid) && isResponseHandled(args, exchange)) {
|
if ((value == null || asyncVoid) && isResponseHandled(args, exchange)) {
|
||||||
return asyncVoid ? Mono.from(adapter.toPublisher(value)) : Mono.empty();
|
return (asyncVoid ? Mono.from(adapter.toPublisher(value)) : Mono.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
HandlerResult result = new HandlerResult(this, value, returnType, bindingContext);
|
HandlerResult result = new HandlerResult(this, value, returnType, bindingContext);
|
||||||
|
|
@ -169,8 +169,8 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Mono<Object[]> resolveArguments(ServerWebExchange exchange, BindingContext bindingContext,
|
private Mono<Object[]> resolveArguments(
|
||||||
Object... providedArgs) {
|
ServerWebExchange exchange, BindingContext bindingContext, Object... providedArgs) {
|
||||||
|
|
||||||
if (ObjectUtils.isEmpty(getMethodParameters())) {
|
if (ObjectUtils.isEmpty(getMethodParameters())) {
|
||||||
return EMPTY_ARGS;
|
return EMPTY_ARGS;
|
||||||
|
|
|
||||||
|
|
@ -487,8 +487,8 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
|
||||||
public RequestMappingInfo build() {
|
public RequestMappingInfo build() {
|
||||||
RequestedContentTypeResolver contentTypeResolver = this.options.getContentTypeResolver();
|
RequestedContentTypeResolver contentTypeResolver = this.options.getContentTypeResolver();
|
||||||
|
|
||||||
PathPatternParser parser = this.options.getPatternParser() != null ?
|
PathPatternParser parser = (this.options.getPatternParser() != null ?
|
||||||
this.options.getPatternParser() : new PathPatternParser();
|
this.options.getPatternParser() : new PathPatternParser());
|
||||||
PatternsRequestCondition patternsCondition = new PatternsRequestCondition(parse(this.paths, parser));
|
PatternsRequestCondition patternsCondition = new PatternsRequestCondition(parse(this.paths, parser));
|
||||||
|
|
||||||
return new RequestMappingInfo(this.mappingName, patternsCondition,
|
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 messageReaders readers to convert from the request body
|
||||||
* @param adapterRegistry for adapting to other reactive types from Flux and Mono
|
* @param adapterRegistry for adapting to other reactive types from Flux and Mono
|
||||||
*/
|
*/
|
||||||
protected AbstractMessageReaderArgumentResolver(List<HttpMessageReader<?>> messageReaders,
|
protected AbstractMessageReaderArgumentResolver(
|
||||||
ReactiveAdapterRegistry adapterRegistry) {
|
List<HttpMessageReader<?>> messageReaders, ReactiveAdapterRegistry adapterRegistry) {
|
||||||
|
|
||||||
super(adapterRegistry);
|
super(adapterRegistry);
|
||||||
Assert.notEmpty(messageReaders, "At least one HttpMessageReader is required");
|
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,
|
protected Mono<Object> readBody(MethodParameter bodyParameter, boolean isBodyRequired,
|
||||||
BindingContext bindingContext, ServerWebExchange exchange) {
|
BindingContext bindingContext, ServerWebExchange exchange) {
|
||||||
|
|
||||||
return this.readBody(bodyParameter, null, isBodyRequired, bindingContext, 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) {
|
boolean isBodyRequired, BindingContext bindingContext, ServerWebExchange exchange) {
|
||||||
|
|
||||||
ResolvableType bodyType = ResolvableType.forMethodParameter(bodyParam);
|
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();
|
Class<?> resolvedType = bodyType.resolve();
|
||||||
ReactiveAdapter adapter = (resolvedType != null ? getAdapterRegistry().getAdapter(resolvedType) : null);
|
ReactiveAdapter adapter = (resolvedType != null ? getAdapterRegistry().getAdapter(resolvedType) : null);
|
||||||
ResolvableType elementType = (adapter != null ? bodyType.getGeneric() : bodyType);
|
ResolvableType elementType = (adapter != null ? bodyType.getGeneric() : bodyType);
|
||||||
|
|
@ -190,7 +191,7 @@ public abstract class AbstractMessageReaderArgumentResolver extends HandlerMetho
|
||||||
mono = mono.doOnNext(target ->
|
mono = mono.doOnNext(target ->
|
||||||
validate(target, hints, bodyParam, bindingContext, exchange));
|
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}.
|
* Write a given body to the response with {@link HttpMessageWriter}.
|
||||||
* @param body the object to write
|
* @param body the object to write
|
||||||
* @param bodyParameter the {@link MethodParameter} of the body to write
|
* @param bodyParameter the {@link MethodParameter} of the body to write
|
||||||
* @param actualParameter the actual return type of the method that returned the
|
* @param actualParam the actual return type of the method that returned the value;
|
||||||
* value; could be different from {@code bodyParameter} when processing {@code HttpEntity}
|
* could be different from {@code bodyParameter} when processing {@code HttpEntity}
|
||||||
* for example
|
* for example
|
||||||
* @param exchange the current exchange
|
* @param exchange the current exchange
|
||||||
* @return indicates completion or error
|
* @return indicates completion or error
|
||||||
|
|
@ -112,11 +112,10 @@ public abstract class AbstractMessageWriterResultHandler extends HandlerResultHa
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
protected Mono<Void> writeBody(@Nullable Object body, MethodParameter bodyParameter,
|
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 bodyType = ResolvableType.forMethodParameter(bodyParameter);
|
||||||
ResolvableType actualType = (actualParameter == null ?
|
ResolvableType actualType = (actualParam != null ? ResolvableType.forMethodParameter(actualParam) : bodyType);
|
||||||
bodyType : ResolvableType.forMethodParameter(actualParameter));
|
|
||||||
Class<?> bodyClass = bodyType.resolve();
|
Class<?> bodyClass = bodyType.resolve();
|
||||||
ReactiveAdapter adapter = getAdapterRegistry().getAdapter(bodyClass, body);
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 class HttpEntityArgumentResolver extends AbstractMessageReaderArgumentResolver {
|
||||||
|
|
||||||
public HttpEntityArgumentResolver(List<HttpMessageReader<?>> readers,
|
public HttpEntityArgumentResolver(List<HttpMessageReader<?>> readers, ReactiveAdapterRegistry registry) {
|
||||||
ReactiveAdapterRegistry registry) {
|
|
||||||
|
|
||||||
super(readers, registry);
|
super(readers, registry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,9 +62,9 @@ public class HttpEntityArgumentResolver extends AbstractMessageReaderArgumentRes
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object createEntity(@Nullable Object body, Class<?> entityType, ServerHttpRequest request) {
|
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 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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 class PrincipalArgumentResolver extends HandlerMethodArgumentResolverSupport {
|
||||||
|
|
||||||
|
|
||||||
public PrincipalArgumentResolver(ReactiveAdapterRegistry adapterRegistry) {
|
public PrincipalArgumentResolver(ReactiveAdapterRegistry adapterRegistry) {
|
||||||
super(adapterRegistry);
|
super(adapterRegistry);
|
||||||
}
|
}
|
||||||
|
|
@ -48,12 +47,12 @@ public class PrincipalArgumentResolver extends HandlerMethodArgumentResolverSupp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mono<Object> resolveArgument(MethodParameter parameter, BindingContext context,
|
public Mono<Object> resolveArgument(
|
||||||
ServerWebExchange exchange) {
|
MethodParameter parameter, BindingContext context, ServerWebExchange exchange) {
|
||||||
|
|
||||||
Mono<Principal> principal = exchange.getPrincipal();
|
Mono<Principal> principal = exchange.getPrincipal();
|
||||||
ReactiveAdapter adapter = getAdapterRegistry().getAdapter(parameter.getParameterType());
|
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,7 +51,6 @@ import org.springframework.web.server.ServerWebInputException;
|
||||||
*/
|
*/
|
||||||
public class RequestPartMethodArgumentResolver extends AbstractMessageReaderArgumentResolver {
|
public class RequestPartMethodArgumentResolver extends AbstractMessageReaderArgumentResolver {
|
||||||
|
|
||||||
|
|
||||||
public RequestPartMethodArgumentResolver(List<HttpMessageReader<?>> readers,
|
public RequestPartMethodArgumentResolver(List<HttpMessageReader<?>> readers,
|
||||||
ReactiveAdapterRegistry registry) {
|
ReactiveAdapterRegistry registry) {
|
||||||
|
|
||||||
|
|
@ -78,9 +77,7 @@ public class RequestPartMethodArgumentResolver extends AbstractMessageReaderArgu
|
||||||
.flatMapMany(map -> {
|
.flatMapMany(map -> {
|
||||||
List<Part> list = map.get(name);
|
List<Part> list = map.get(name);
|
||||||
if (CollectionUtils.isEmpty(list)) {
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
return isRequired ?
|
return (isRequired ? Flux.error(getMissingPartException(name, parameter)) : Flux.empty());
|
||||||
Flux.error(getMissingPartException(name, parameter)) :
|
|
||||||
Flux.empty();
|
|
||||||
}
|
}
|
||||||
return Flux.fromIterable(list);
|
return Flux.fromIterable(list);
|
||||||
});
|
});
|
||||||
|
|
@ -105,7 +102,7 @@ public class RequestPartMethodArgumentResolver extends AbstractMessageReaderArgu
|
||||||
// Mono<Part> or Flux<Part>
|
// Mono<Part> or Flux<Part>
|
||||||
MethodParameter elementType = parameter.nested();
|
MethodParameter elementType = parameter.nested();
|
||||||
if (Part.class.isAssignableFrom(elementType.getNestedParameterType())) {
|
if (Part.class.isAssignableFrom(elementType.getNestedParameterType())) {
|
||||||
parts = adapter.isMultiValue() ? parts : parts.take(1);
|
parts = (adapter.isMultiValue() ? parts : parts.take(1));
|
||||||
return Mono.just(adapter.fromPublisher(parts));
|
return Mono.just(adapter.fromPublisher(parts));
|
||||||
}
|
}
|
||||||
// We have to decode the content for each part, one at a time
|
// We have to decode the content for each part, one at a time
|
||||||
|
|
|
||||||
|
|
@ -102,12 +102,12 @@ public class ServerWebExchangeArgumentResolver extends HandlerMethodArgumentReso
|
||||||
else if (TimeZone.class == paramType) {
|
else if (TimeZone.class == paramType) {
|
||||||
LocaleContext localeContext = exchange.getLocaleContext();
|
LocaleContext localeContext = exchange.getLocaleContext();
|
||||||
TimeZone timeZone = getTimeZone(localeContext);
|
TimeZone timeZone = getTimeZone(localeContext);
|
||||||
return timeZone != null ? timeZone : TimeZone.getDefault();
|
return (timeZone != null ? timeZone : TimeZone.getDefault());
|
||||||
}
|
}
|
||||||
else if (ZoneId.class == paramType) {
|
else if (ZoneId.class == paramType) {
|
||||||
LocaleContext localeContext = exchange.getLocaleContext();
|
LocaleContext localeContext = exchange.getLocaleContext();
|
||||||
TimeZone timeZone = getTimeZone(localeContext);
|
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) {
|
else if (UriBuilder.class == paramType || UriComponentsBuilder.class == paramType) {
|
||||||
URI uri = exchange.getRequest().getURI();
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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();
|
Mono<WebSession> session = exchange.getSession();
|
||||||
ReactiveAdapter adapter = getAdapterRegistry().getAdapter(parameter.getParameterType());
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -23,8 +23,6 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.reactivestreams.Publisher;
|
import org.reactivestreams.Publisher;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
|
@ -45,9 +43,6 @@ import org.springframework.web.server.ServerWebExchange;
|
||||||
*/
|
*/
|
||||||
public class HttpMessageWriterView implements View {
|
public class HttpMessageWriterView implements View {
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(HttpMessageWriter.class);
|
|
||||||
|
|
||||||
|
|
||||||
private final HttpMessageWriter<?> writer;
|
private final HttpMessageWriter<?> writer;
|
||||||
|
|
||||||
private final Set<String> modelKeys = new HashSet<>(4);
|
private final Set<String> modelKeys = new HashSet<>(4);
|
||||||
|
|
@ -66,7 +61,7 @@ public class HttpMessageWriterView implements View {
|
||||||
* Constructor with a fully initialized {@link HttpMessageWriter}.
|
* Constructor with a fully initialized {@link HttpMessageWriter}.
|
||||||
*/
|
*/
|
||||||
public HttpMessageWriterView(HttpMessageWriter<?> writer) {
|
public HttpMessageWriterView(HttpMessageWriter<?> writer) {
|
||||||
Assert.notNull(writer, "'writer' is required.");
|
Assert.notNull(writer, "HttpMessageWriter is required");
|
||||||
this.writer = writer;
|
this.writer = writer;
|
||||||
this.canWriteMap = writer.canWrite(ResolvableType.forClass(Map.class), null);
|
this.canWriteMap = writer.canWrite(ResolvableType.forClass(Map.class), null);
|
||||||
}
|
}
|
||||||
|
|
@ -118,12 +113,11 @@ public class HttpMessageWriterView implements View {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Mono<Void> render(@Nullable Map<String, ?> model, @Nullable MediaType contentType,
|
public Mono<Void> render(
|
||||||
ServerWebExchange exchange) {
|
@Nullable Map<String, ?> model, @Nullable MediaType contentType, ServerWebExchange exchange) {
|
||||||
|
|
||||||
Object value = getObjectToRender(model);
|
Object value = getObjectToRender(model);
|
||||||
return (value != null) ?
|
return (value != null ? write(value, contentType, exchange) : exchange.getResponse().setComplete());
|
||||||
write(value, contentType, exchange) : exchange.getResponse().setComplete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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) {
|
if (this.resourceLoaderPaths == null) {
|
||||||
String resourceLoaderPath = viewConfig.getResourceLoaderPath();
|
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) {
|
if (this.sharedEngine == null && viewConfig.isSharedEngine() != null) {
|
||||||
this.sharedEngine = viewConfig.isSharedEngine();
|
this.sharedEngine = viewConfig.isSharedEngine();
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,8 @@ public abstract class AbstractListenerWebSocketSession<T> extends AbstractWebSoc
|
||||||
* @param handshakeInfo the handshake info
|
* @param handshakeInfo the handshake info
|
||||||
* @param bufferFactory the DataBuffer factor for the current connection
|
* @param bufferFactory the DataBuffer factor for the current connection
|
||||||
*/
|
*/
|
||||||
public AbstractListenerWebSocketSession(T delegate, String id, HandshakeInfo handshakeInfo,
|
public AbstractListenerWebSocketSession(
|
||||||
DataBufferFactory bufferFactory) {
|
T delegate, String id, HandshakeInfo handshakeInfo, DataBufferFactory bufferFactory) {
|
||||||
|
|
||||||
this(delegate, id, handshakeInfo, bufferFactory, null);
|
this(delegate, id, handshakeInfo, bufferFactory, null);
|
||||||
}
|
}
|
||||||
|
|
@ -106,9 +106,8 @@ public abstract class AbstractListenerWebSocketSession<T> extends AbstractWebSoc
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Flux<WebSocketMessage> receive() {
|
public Flux<WebSocketMessage> receive() {
|
||||||
return canSuspendReceiving() ?
|
return (canSuspendReceiving() ? Flux.from(this.receivePublisher) :
|
||||||
Flux.from(this.receivePublisher) :
|
Flux.from(this.receivePublisher).onBackpressureBuffer(RECEIVE_BUFFER_SIZE));
|
||||||
Flux.from(this.receivePublisher).onBackpressureBuffer(RECEIVE_BUFFER_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ import org.springframework.web.reactive.socket.adapter.JettyWebSocketSession;
|
||||||
import org.springframework.web.reactive.socket.server.RequestUpgradeStrategy;
|
import org.springframework.web.reactive.socket.server.RequestUpgradeStrategy;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link RequestUpgradeStrategy} for use with Jetty.
|
* A {@link RequestUpgradeStrategy} for use with Jetty.
|
||||||
*
|
*
|
||||||
|
|
@ -95,9 +94,9 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life
|
||||||
if (!isRunning() && servletContext != null) {
|
if (!isRunning() && servletContext != null) {
|
||||||
this.running = true;
|
this.running = true;
|
||||||
try {
|
try {
|
||||||
this.factory = this.webSocketPolicy != null ?
|
this.factory = (this.webSocketPolicy != null ?
|
||||||
new WebSocketServerFactory(servletContext, this.webSocketPolicy) :
|
new WebSocketServerFactory(servletContext, this.webSocketPolicy) :
|
||||||
new WebSocketServerFactory(servletContext);
|
new WebSocketServerFactory(servletContext));
|
||||||
this.factory.setCreator((request, response) -> {
|
this.factory.setCreator((request, response) -> {
|
||||||
WebSocketHandlerContainer container = adapterHolder.get();
|
WebSocketHandlerContainer container = adapterHolder.get();
|
||||||
String protocol = container.getProtocol();
|
String protocol = container.getProtocol();
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class HeadersRequestConditionTests {
|
||||||
public void headerEquals() {
|
public void headerEquals() {
|
||||||
assertEquals(new HeadersRequestCondition("foo"), new HeadersRequestCondition("foo"));
|
assertEquals(new HeadersRequestCondition("foo"), new HeadersRequestCondition("foo"));
|
||||||
assertEquals(new HeadersRequestCondition("foo"), new HeadersRequestCondition("FOO"));
|
assertEquals(new HeadersRequestCondition("foo"), new HeadersRequestCondition("FOO"));
|
||||||
assertFalse(new HeadersRequestCondition("foo").equals(new HeadersRequestCondition("bar")));
|
assertNotEquals(new HeadersRequestCondition("foo"), new HeadersRequestCondition("bar"));
|
||||||
assertEquals(new HeadersRequestCondition("foo=bar"), new HeadersRequestCondition("foo=bar"));
|
assertEquals(new HeadersRequestCondition("foo=bar"), new HeadersRequestCondition("foo=bar"));
|
||||||
assertEquals(new HeadersRequestCondition("foo=bar"), new HeadersRequestCondition("FOO=bar"));
|
assertEquals(new HeadersRequestCondition("foo=bar"), new HeadersRequestCondition("FOO=bar"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -129,7 +129,9 @@ public class PathMatchConfigurer {
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
public PathMatchConfigurer addPathPrefix(String prefix, Predicate<Class<?>> predicate) {
|
public PathMatchConfigurer addPathPrefix(String prefix, Predicate<Class<?>> predicate) {
|
||||||
this.pathPrefixes = this.pathPrefixes == null ? new LinkedHashMap<>() : this.pathPrefixes;
|
if (this.pathPrefixes == null) {
|
||||||
|
this.pathPrefixes = new LinkedHashMap<>();
|
||||||
|
}
|
||||||
this.pathPrefixes.put(prefix, predicate);
|
this.pathPrefixes.put(prefix, predicate);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -74,16 +74,16 @@ abstract class AbstractMediaTypeExpression implements MediaTypeExpression, Compa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object obj) {
|
public boolean equals(@Nullable Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj != null && getClass() == obj.getClass()) {
|
if (other == null || getClass() != other.getClass()) {
|
||||||
AbstractMediaTypeExpression other = (AbstractMediaTypeExpression) obj;
|
|
||||||
return (this.mediaType.equals(other.mediaType) && this.isNegated == other.isNegated);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
AbstractMediaTypeExpression otherExpr = (AbstractMediaTypeExpression) other;
|
||||||
|
return (this.mediaType.equals(otherExpr.mediaType) && this.isNegated == otherExpr.isNegated);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package org.springframework.web.servlet.mvc.condition;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supports "name=value" style expressions as described in:
|
* Supports "name=value" style expressions as described in:
|
||||||
|
|
@ -93,20 +94,17 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(@Nullable Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj instanceof AbstractNameValueExpression) {
|
if (other == null || getClass() != other.getClass()) {
|
||||||
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);
|
|
||||||
}
|
|
||||||
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
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
|
||||||
|
|
@ -57,16 +57,15 @@ public abstract class AbstractRequestCondition<T extends AbstractRequestConditio
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object obj) {
|
public boolean equals(@Nullable Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj != null && getClass() == obj.getClass()) {
|
if (other == null || getClass() != other.getClass()) {
|
||||||
AbstractRequestCondition<?> other = (AbstractRequestCondition<?>) obj;
|
|
||||||
return getContent().equals(other.getContent());
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return getContent().equals(((AbstractRequestCondition<?>) other).getContent());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ public class CompositeRequestCondition extends AbstractRequestCondition<Composit
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<?> getContent() {
|
protected Collection<?> getContent() {
|
||||||
return (isEmpty()) ? Collections.emptyList() : getConditions();
|
return (!isEmpty() ? getConditions() : Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition<Con
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ConsumesRequestCondition combine(ConsumesRequestCondition other) {
|
public ConsumesRequestCondition combine(ConsumesRequestCondition other) {
|
||||||
return !other.expressions.isEmpty() ? other : this;
|
return (!other.expressions.isEmpty() ? other : this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue