Skip to content

Commit 87b1b61

Browse files
committed
Polishing
1 parent 3b09456 commit 87b1b61

File tree

6 files changed

+36
-29
lines changed

6 files changed

+36
-29
lines changed

spring-core/src/main/java/org/springframework/core/OrderComparator.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,10 @@
2727
* {@link Comparator} implementation for {@link Ordered} objects, sorting
2828
* by order value ascending, respectively by priority descending.
2929
*
30+
* <h3>{@code PriorityOrdered} Objects</h3>
31+
* <p>{@link PriorityOrdered} objects will be sorted with higher priority than
32+
* <em>plain</em> {@code Ordered} objects.
33+
*
3034
* <h3>Same Order Objects</h3>
3135
* <p>Objects that have the same order value will be sorted with arbitrary
3236
* ordering with respect to other objects with the same order value.
@@ -41,6 +45,7 @@
4145
* @author Sam Brannen
4246
* @since 07.04.2003
4347
* @see Ordered
48+
* @see PriorityOrdered
4449
* @see org.springframework.core.annotation.AnnotationAwareOrderComparator
4550
* @see java.util.List#sort(java.util.Comparator)
4651
* @see java.util.Arrays#sort(Object[], java.util.Comparator)
@@ -96,8 +101,7 @@ private int getOrder(@Nullable Object obj, @Nullable OrderSourceProvider sourceP
96101
Object orderSource = sourceProvider.getOrderSource(obj);
97102
if (orderSource != null) {
98103
if (orderSource.getClass().isArray()) {
99-
Object[] sources = ObjectUtils.toObjectArray(orderSource);
100-
for (Object source : sources) {
104+
for (Object source : ObjectUtils.toObjectArray(orderSource)) {
101105
order = findOrder(source);
102106
if (order != null) {
103107
break;

spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AbstractNamedValueMethodArgumentResolver.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -149,8 +149,9 @@ private NamedValueInfo updateNamedValueInfo(MethodParameter parameter, NamedValu
149149
if (info.name.isEmpty()) {
150150
name = parameter.getParameterName();
151151
if (name == null) {
152-
throw new IllegalArgumentException("Name for argument type [" + parameter.getParameterType().getName() +
153-
"] not available, and parameter name information not found in class file either.");
152+
throw new IllegalArgumentException(
153+
"Name for argument of type [" + parameter.getNestedParameterType().getName() +
154+
"] not specified, and parameter name information not found in class file either.");
154155
}
155156
}
156157
String defaultValue = (ValueConstants.DEFAULT_NONE.equals(info.defaultValue) ? null : info.defaultValue);

spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/DefaultStompSession.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
111111
private final Map<String, ReceiptHandler> receiptHandlers = new ConcurrentHashMap<>(4);
112112

113113
/* Whether the client is willfully closing the connection */
114-
private volatile boolean closing = false;
114+
private volatile boolean closing;
115115

116116

117117
/**
@@ -256,7 +256,7 @@ private StompHeaderAccessor createHeaderAccessor(StompCommand command) {
256256
private Message<byte[]> createMessage(StompHeaderAccessor accessor, @Nullable Object payload) {
257257
accessor.updateSimpMessageHeadersFromStompHeaders();
258258
Message<byte[]> message;
259-
if (isEmpty(payload)) {
259+
if (StringUtils.isEmpty(payload) || (payload instanceof byte[] && ((byte[]) payload).length == 0)) {
260260
message = MessageBuilder.createMessage(EMPTY_PAYLOAD, accessor.getMessageHeaders());
261261
}
262262
else {
@@ -271,10 +271,6 @@ private Message<byte[]> createMessage(StompHeaderAccessor accessor, @Nullable Ob
271271
return message;
272272
}
273273

274-
private boolean isEmpty(@Nullable Object payload) {
275-
return (StringUtils.isEmpty(payload) || (payload instanceof byte[] && ((byte[]) payload).length == 0));
276-
}
277-
278274
private void execute(Message<byte[]> message) {
279275
if (logger.isTraceEnabled()) {
280276
StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);

spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -131,7 +131,6 @@ else if ("".equals(arg) && namedValueInfo.defaultValue != null) {
131131
catch (TypeMismatchException ex) {
132132
throw new MethodArgumentTypeMismatchException(arg, ex.getRequiredType(),
133133
namedValueInfo.name, parameter, ex.getCause());
134-
135134
}
136135
}
137136

@@ -170,8 +169,8 @@ private NamedValueInfo updateNamedValueInfo(MethodParameter parameter, NamedValu
170169
name = parameter.getParameterName();
171170
if (name == null) {
172171
throw new IllegalArgumentException(
173-
"Name for argument type [" + parameter.getNestedParameterType().getName() +
174-
"] not available, and parameter name information not found in class file either.");
172+
"Name for argument of type [" + parameter.getNestedParameterType().getName() +
173+
"] not specified, and parameter name information not found in class file either.");
175174
}
176175
}
177176
String defaultValue = (ValueConstants.DEFAULT_NONE.equals(info.defaultValue) ? null : info.defaultValue);
@@ -184,12 +183,12 @@ private NamedValueInfo updateNamedValueInfo(MethodParameter parameter, NamedValu
184183
*/
185184
@Nullable
186185
private Object resolveStringValue(String value) {
187-
if (this.configurableBeanFactory == null) {
186+
if (this.configurableBeanFactory == null || this.expressionContext == null) {
188187
return value;
189188
}
190189
String placeholdersResolved = this.configurableBeanFactory.resolveEmbeddedValue(value);
191190
BeanExpressionResolver exprResolver = this.configurableBeanFactory.getBeanExpressionResolver();
192-
if (exprResolver == null || this.expressionContext == null) {
191+
if (exprResolver == null) {
193192
return value;
194193
}
195194
return exprResolver.evaluate(placeholdersResolved, this.expressionContext);

spring-web/src/main/java/org/springframework/web/multipart/support/MissingServletRequestPartException.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@
2626
*
2727
* <p>This may be because the request is not a multipart/form-data request,
2828
* because the part is not present in the request, or because the web
29-
* application is not configured correctly for processing multipart requests,
29+
* application is not configured correctly for processing multipart requests,
3030
* e.g. no {@link MultipartResolver}.
3131
*
3232
* @author Rossen Stoyanchev
@@ -35,17 +35,24 @@
3535
@SuppressWarnings("serial")
3636
public class MissingServletRequestPartException extends ServletException {
3737

38-
private final String partName;
38+
private final String requestPartName;
3939

4040

41-
public MissingServletRequestPartException(String partName) {
42-
super("Required request part '" + partName + "' is not present");
43-
this.partName = partName;
41+
/**
42+
* Constructor for MissingServletRequestPartException.
43+
* @param requestPartName the name of the missing part of the multipart request
44+
*/
45+
public MissingServletRequestPartException(String requestPartName) {
46+
super("Required request part '" + requestPartName + "' is not present");
47+
this.requestPartName = requestPartName;
4448
}
4549

4650

51+
/**
52+
* Return the name of the offending part of the multipart request.
53+
*/
4754
public String getRequestPartName() {
48-
return this.partName;
55+
return this.requestPartName;
4956
}
5057

5158
}

spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -144,9 +144,9 @@ private NamedValueInfo updateNamedValueInfo(MethodParameter parameter, NamedValu
144144
if (info.name.isEmpty()) {
145145
name = parameter.getParameterName();
146146
if (name == null) {
147-
String type = parameter.getNestedParameterType().getName();
148-
throw new IllegalArgumentException("Name for argument type [" + type + "] not " +
149-
"available, and parameter name information not found in class file either.");
147+
throw new IllegalArgumentException(
148+
"Name for argument of type [" + parameter.getNestedParameterType().getName() +
149+
"] not specified, and parameter name information not found in class file either.");
150150
}
151151
}
152152
String defaultValue = (ValueConstants.DEFAULT_NONE.equals(info.defaultValue) ? null : info.defaultValue);

0 commit comments

Comments
 (0)