Polishing
This commit is contained in:
parent
69c330d905
commit
66a67ec807
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -101,8 +101,7 @@ public class OrderComparator implements Comparator<Object> {
|
|||
Object orderSource = sourceProvider.getOrderSource(obj);
|
||||
if (orderSource != null) {
|
||||
if (orderSource.getClass().isArray()) {
|
||||
Object[] sources = ObjectUtils.toObjectArray(orderSource);
|
||||
for (Object source : sources) {
|
||||
for (Object source : ObjectUtils.toObjectArray(orderSource)) {
|
||||
order = findOrder(source);
|
||||
if (order != null) {
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -82,7 +82,6 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements SyncHa
|
|||
|
||||
@Override
|
||||
public Object resolveArgumentValue(MethodParameter parameter, Message<?> message) {
|
||||
|
||||
NamedValueInfo namedValueInfo = getNamedValueInfo(parameter);
|
||||
MethodParameter nestedParameter = parameter.nestedIfOptional();
|
||||
|
||||
|
|
@ -144,10 +143,9 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements SyncHa
|
|||
if (info.name.isEmpty()) {
|
||||
name = parameter.getParameterName();
|
||||
if (name == null) {
|
||||
Class<?> type = parameter.getParameterType();
|
||||
throw new IllegalArgumentException(
|
||||
"Name for argument of type [" + type.getName() + "] not specified, " +
|
||||
"and parameter name information not found in class file either.");
|
||||
"Name for argument of type [" + parameter.getNestedParameterType().getName() +
|
||||
"] not specified, and parameter name information not found in class file either.");
|
||||
}
|
||||
}
|
||||
return new NamedValueInfo(name, info.required,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -80,8 +80,8 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
|||
// Possibly remove after discussion in gh-23882.
|
||||
|
||||
//noinspection ConstantConditions
|
||||
this.conversionService = conversionService != null ?
|
||||
conversionService : DefaultConversionService.getSharedInstance();
|
||||
this.conversionService = (conversionService != null ?
|
||||
conversionService : DefaultConversionService.getSharedInstance());
|
||||
|
||||
this.configurableBeanFactory = beanFactory;
|
||||
this.expressionContext = (beanFactory != null ? new BeanExpressionContext(beanFactory, null) : null);
|
||||
|
|
@ -154,10 +154,9 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
|||
if (info.name.isEmpty()) {
|
||||
name = parameter.getParameterName();
|
||||
if (name == null) {
|
||||
Class<?> type = parameter.getParameterType();
|
||||
throw new IllegalArgumentException(
|
||||
"Name for argument of type [" + type.getName() + "] not specified, " +
|
||||
"and parameter name information not found in class file either.");
|
||||
"Name for argument of type [" + parameter.getNestedParameterType().getName() +
|
||||
"] not specified, and parameter name information not found in class file either.");
|
||||
}
|
||||
}
|
||||
return new NamedValueInfo(name, info.required,
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
|
|||
private final Map<String, ReceiptHandler> receiptHandlers = new ConcurrentHashMap<>(4);
|
||||
|
||||
/* Whether the client is willfully closing the connection */
|
||||
private volatile boolean closing = false;
|
||||
private volatile boolean closing;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -256,7 +256,7 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
|
|||
private Message<byte[]> createMessage(StompHeaderAccessor accessor, @Nullable Object payload) {
|
||||
accessor.updateSimpMessageHeadersFromStompHeaders();
|
||||
Message<byte[]> message;
|
||||
if (isEmpty(payload)) {
|
||||
if (StringUtils.isEmpty(payload) || (payload instanceof byte[] && ((byte[]) payload).length == 0)) {
|
||||
message = MessageBuilder.createMessage(EMPTY_PAYLOAD, accessor.getMessageHeaders());
|
||||
}
|
||||
else {
|
||||
|
|
@ -271,10 +271,6 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
|
|||
return message;
|
||||
}
|
||||
|
||||
private boolean isEmpty(@Nullable Object payload) {
|
||||
return (StringUtils.isEmpty(payload) || (payload instanceof byte[] && ((byte[]) payload).length == 0));
|
||||
}
|
||||
|
||||
private void execute(Message<byte[]> message) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -99,7 +99,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
|||
NamedValueInfo namedValueInfo = getNamedValueInfo(parameter);
|
||||
MethodParameter nestedParameter = parameter.nestedIfOptional();
|
||||
|
||||
Object resolvedName = resolveStringValue(namedValueInfo.name);
|
||||
Object resolvedName = resolveEmbeddedValuesAndExpressions(namedValueInfo.name);
|
||||
if (resolvedName == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Specified name must not resolve to null: [" + namedValueInfo.name + "]");
|
||||
|
|
@ -108,7 +108,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
|||
Object arg = resolveName(resolvedName.toString(), nestedParameter, webRequest);
|
||||
if (arg == null) {
|
||||
if (namedValueInfo.defaultValue != null) {
|
||||
arg = resolveStringValue(namedValueInfo.defaultValue);
|
||||
arg = resolveEmbeddedValuesAndExpressions(namedValueInfo.defaultValue);
|
||||
}
|
||||
else if (namedValueInfo.required && !nestedParameter.isOptional()) {
|
||||
handleMissingValue(namedValueInfo.name, nestedParameter, webRequest);
|
||||
|
|
@ -116,7 +116,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
|||
arg = handleNullValue(namedValueInfo.name, arg, nestedParameter.getNestedParameterType());
|
||||
}
|
||||
else if ("".equals(arg) && namedValueInfo.defaultValue != null) {
|
||||
arg = resolveStringValue(namedValueInfo.defaultValue);
|
||||
arg = resolveEmbeddedValuesAndExpressions(namedValueInfo.defaultValue);
|
||||
}
|
||||
|
||||
if (binderFactory != null) {
|
||||
|
|
@ -169,8 +169,8 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
|||
name = parameter.getParameterName();
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Name for argument type [" + parameter.getNestedParameterType().getName() +
|
||||
"] not available, and parameter name information not found in class file either.");
|
||||
"Name for argument of type [" + parameter.getNestedParameterType().getName() +
|
||||
"] not specified, and parameter name information not found in class file either.");
|
||||
}
|
||||
}
|
||||
String defaultValue = (ValueConstants.DEFAULT_NONE.equals(info.defaultValue) ? null : info.defaultValue);
|
||||
|
|
@ -182,13 +182,13 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
|||
* potentially containing placeholders and expressions.
|
||||
*/
|
||||
@Nullable
|
||||
private Object resolveStringValue(String value) {
|
||||
if (this.configurableBeanFactory == null) {
|
||||
private Object resolveEmbeddedValuesAndExpressions(String value) {
|
||||
if (this.configurableBeanFactory == null || this.expressionContext == null) {
|
||||
return value;
|
||||
}
|
||||
String placeholdersResolved = this.configurableBeanFactory.resolveEmbeddedValue(value);
|
||||
BeanExpressionResolver exprResolver = this.configurableBeanFactory.getBeanExpressionResolver();
|
||||
if (exprResolver == null || this.expressionContext == null) {
|
||||
if (exprResolver == null) {
|
||||
return value;
|
||||
}
|
||||
return exprResolver.evaluate(placeholdersResolved, this.expressionContext);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -26,7 +26,7 @@ import org.springframework.web.multipart.MultipartResolver;
|
|||
*
|
||||
* <p>This may be because the request is not a multipart/form-data request,
|
||||
* because the part is not present in the request, or because the web
|
||||
* application is not configured correctly for processing multipart requests,
|
||||
* application is not configured correctly for processing multipart requests,
|
||||
* e.g. no {@link MultipartResolver}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
|
|
@ -35,17 +35,24 @@ import org.springframework.web.multipart.MultipartResolver;
|
|||
@SuppressWarnings("serial")
|
||||
public class MissingServletRequestPartException extends ServletException {
|
||||
|
||||
private final String partName;
|
||||
private final String requestPartName;
|
||||
|
||||
|
||||
public MissingServletRequestPartException(String partName) {
|
||||
super("Required request part '" + partName + "' is not present");
|
||||
this.partName = partName;
|
||||
/**
|
||||
* Constructor for MissingServletRequestPartException.
|
||||
* @param requestPartName the name of the missing part of the multipart request
|
||||
*/
|
||||
public MissingServletRequestPartException(String requestPartName) {
|
||||
super("Required request part '" + requestPartName + "' is not present");
|
||||
this.requestPartName = requestPartName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the offending part of the multipart request.
|
||||
*/
|
||||
public String getRequestPartName() {
|
||||
return this.partName;
|
||||
return this.requestPartName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -144,9 +144,9 @@ public abstract class AbstractNamedValueArgumentResolver extends HandlerMethodAr
|
|||
if (info.name.isEmpty()) {
|
||||
name = parameter.getParameterName();
|
||||
if (name == null) {
|
||||
String type = parameter.getNestedParameterType().getName();
|
||||
throw new IllegalArgumentException("Name for argument type [" + type + "] not " +
|
||||
"available, and parameter name information not found in class file either.");
|
||||
throw new IllegalArgumentException(
|
||||
"Name for argument of type [" + parameter.getNestedParameterType().getName() +
|
||||
"] not specified, and parameter name information not found in class file either.");
|
||||
}
|
||||
}
|
||||
String defaultValue = (ValueConstants.DEFAULT_NONE.equals(info.defaultValue) ? null : info.defaultValue);
|
||||
|
|
|
|||
Loading…
Reference in New Issue