Skip to content

Commit 8323c87

Browse files
committed
Polishing
1 parent 0c65a5e commit 8323c87

File tree

8 files changed

+42
-42
lines changed

8 files changed

+42
-42
lines changed

Diff for: spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 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.
@@ -126,10 +126,16 @@ public AspectMetadata(Class<?> aspectClass, String aspectName) {
126126
* Extract contents from String of form {@code pertarget(contents)}.
127127
*/
128128
private String findPerClause(Class<?> aspectClass) {
129-
String str = aspectClass.getAnnotation(Aspect.class).value();
130-
int beginIndex = str.indexOf('(') + 1;
131-
int endIndex = str.length() - 1;
132-
return str.substring(beginIndex, endIndex);
129+
Aspect ann = aspectClass.getAnnotation(Aspect.class);
130+
if (ann == null) {
131+
return "";
132+
}
133+
String value = ann.value();
134+
int beginIndex = value.indexOf('(');
135+
if (beginIndex < 0) {
136+
return "";
137+
}
138+
return value.substring(beginIndex + 1, value.length() - 1);
133139
}
134140

135141

Diff for: spring-core/src/main/java/org/springframework/util/MultiValueMapAdapter.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2024 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.
@@ -58,7 +58,7 @@ public MultiValueMapAdapter(Map<K, List<V>> targetMap) {
5858
@Nullable
5959
public V getFirst(K key) {
6060
List<V> values = this.targetMap.get(key);
61-
return (values != null && !values.isEmpty() ? values.get(0) : null);
61+
return (!CollectionUtils.isEmpty(values) ? values.get(0) : null);
6262
}
6363

6464
@Override
@@ -69,7 +69,7 @@ public void add(K key, @Nullable V value) {
6969

7070
@Override
7171
public void addAll(K key, List<? extends V> values) {
72-
List<V> currentValues = this.targetMap.computeIfAbsent(key, k -> new ArrayList<>(1));
72+
List<V> currentValues = this.targetMap.computeIfAbsent(key, k -> new ArrayList<>(values.size()));
7373
currentValues.addAll(values);
7474
}
7575

@@ -96,7 +96,7 @@ public void setAll(Map<K, V> values) {
9696
public Map<K, V> toSingleValueMap() {
9797
Map<K, V> singleValueMap = CollectionUtils.newLinkedHashMap(this.targetMap.size());
9898
this.targetMap.forEach((key, values) -> {
99-
if (values != null && !values.isEmpty()) {
99+
if (!CollectionUtils.isEmpty(values)) {
100100
singleValueMap.put(key, values.get(0));
101101
}
102102
});

Diff for: spring-core/src/main/java/org/springframework/util/StringUtils.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 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.
@@ -781,6 +781,7 @@ public static boolean pathEquals(String path1, String path2) {
781781
* and {@code "0"} through {@code "9"} stay the same.</li>
782782
* <li>Special characters {@code "-"}, {@code "_"}, {@code "."}, and {@code "*"} stay the same.</li>
783783
* <li>A sequence "{@code %<i>xy</i>}" is interpreted as a hexadecimal representation of the character.</li>
784+
* <li>For all other characters (including those already decoded), the output is undefined.</li>
784785
* </ul>
785786
* @param source the encoded String
786787
* @param charset the character set
@@ -829,7 +830,7 @@ public static String uriDecode(String source, Charset charset) {
829830
* the {@link Locale#toString} format as well as BCP 47 language tags as
830831
* specified by {@link Locale#forLanguageTag}.
831832
* @param localeValue the locale value: following either {@code Locale's}
832-
* {@code toString()} format ("en", "en_UK", etc), also accepting spaces as
833+
* {@code toString()} format ("en", "en_UK", etc.), also accepting spaces as
833834
* separators (as an alternative to underscores), or BCP 47 (e.g. "en-UK")
834835
* @return a corresponding {@code Locale} instance, or {@code null} if none
835836
* @throws IllegalArgumentException in case of an invalid locale specification
@@ -859,7 +860,7 @@ public static Locale parseLocale(String localeValue) {
859860
* <p><b>Note: This delegate does not accept the BCP 47 language tag format.
860861
* Please use {@link #parseLocale} for lenient parsing of both formats.</b>
861862
* @param localeString the locale {@code String}: following {@code Locale's}
862-
* {@code toString()} format ("en", "en_UK", etc), also accepting spaces as
863+
* {@code toString()} format ("en", "en_UK", etc.), also accepting spaces as
863864
* separators (as an alternative to underscores)
864865
* @return a corresponding {@code Locale} instance, or {@code null} if none
865866
* @throws IllegalArgumentException in case of an invalid locale specification

Diff for: spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2024 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.
@@ -32,7 +32,7 @@
3232
import org.springframework.util.CollectionUtils;
3333

3434
/**
35-
* The default implementation of Spring's {@link SqlRowSet} interface, wrapping a
35+
* The common implementation of Spring's {@link SqlRowSet} interface, wrapping a
3636
* {@link java.sql.ResultSet}, catching any {@link SQLException SQLExceptions} and
3737
* translating them to a corresponding Spring {@link InvalidResultSetAccessException}.
3838
*
@@ -43,17 +43,17 @@
4343
* <p>Note: Since JDBC 4.0, it has been clarified that any methods using a String to identify
4444
* the column should be using the column label. The column label is assigned using the ALIAS
4545
* keyword in the SQL query string. When the query doesn't use an ALIAS, the default label is
46-
* the column name. Most JDBC ResultSet implementations follow this new pattern but there are
46+
* the column name. Most JDBC ResultSet implementations follow this pattern, but there are
4747
* exceptions such as the {@code com.sun.rowset.CachedRowSetImpl} class which only uses
48-
* the column name, ignoring any column labels. As of Spring 3.0.5, ResultSetWrappingSqlRowSet
49-
* will translate column labels to the correct column index to provide better support for the
48+
* the column name, ignoring any column labels. {@code ResultSetWrappingSqlRowSet}
49+
* will translate column labels to the correct column index to provide better support for
5050
* {@code com.sun.rowset.CachedRowSetImpl} which is the default implementation used by
5151
* {@link org.springframework.jdbc.core.JdbcTemplate} when working with RowSets.
5252
*
5353
* <p>Note: This class implements the {@code java.io.Serializable} marker interface
5454
* through the SqlRowSet interface, but is only actually serializable if the disconnected
5555
* ResultSet/RowSet contained in it is serializable. Most CachedRowSet implementations
56-
* are actually serializable, so this should usually work out.
56+
* are actually serializable, so serialization should usually work.
5757
*
5858
* @author Thomas Risberg
5959
* @author Juergen Hoeller
@@ -67,16 +67,18 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
6767
/** use serialVersionUID from Spring 1.2 for interoperability. */
6868
private static final long serialVersionUID = -4688694393146734764L;
6969

70-
70+
@SuppressWarnings("serial")
7171
private final ResultSet resultSet;
7272

73+
@SuppressWarnings("serial")
7374
private final SqlRowSetMetaData rowSetMetaData;
7475

76+
@SuppressWarnings("serial")
7577
private final Map<String, Integer> columnLabelMap;
7678

7779

7880
/**
79-
* Create a new ResultSetWrappingSqlRowSet for the given ResultSet.
81+
* Create a new {@code ResultSetWrappingSqlRowSet} for the given {@link ResultSet}.
8082
* @param resultSet a disconnected ResultSet to wrap
8183
* (usually a {@code javax.sql.rowset.CachedRowSet})
8284
* @throws InvalidResultSetAccessException if extracting

Diff for: spring-jms/src/main/java/org/springframework/jms/core/JmsMessagingTemplate.java

+1-6
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-2024 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.
@@ -189,11 +189,6 @@ public void send(Message<?> message) {
189189
}
190190
}
191191

192-
@Override
193-
public void convertAndSend(Object payload) throws MessagingException {
194-
convertAndSend(payload, null);
195-
}
196-
197192
@Override
198193
public void convertAndSend(Object payload, @Nullable MessagePostProcessor postProcessor) throws MessagingException {
199194
Destination defaultDestination = getDefaultDestination();

Diff for: spring-jms/src/main/java/org/springframework/jms/core/JmsOperations.java

+7-7
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-2024 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.
@@ -290,7 +290,7 @@ void convertAndSend(String destinationName, Object message, MessagePostProcessor
290290
* <p>This method should be used carefully, since it will block the thread
291291
* until the message becomes available or until the timeout value is exceeded.
292292
* <p>This will only work with a default destination specified!
293-
* @return the message produced for the consumer or {@code null} if the timeout expires.
293+
* @return the message produced for the consumer, or {@code null} if the timeout expires
294294
* @throws JmsException checked JMSException converted to unchecked
295295
*/
296296
@Nullable
@@ -303,7 +303,7 @@ void convertAndSend(String destinationName, Object message, MessagePostProcessor
303303
* <p>This method should be used carefully, since it will block the thread
304304
* until the message becomes available or until the timeout value is exceeded.
305305
* @param destination the destination to receive a message from
306-
* @return the message produced for the consumer or {@code null} if the timeout expires.
306+
* @return the message produced for the consumer, or {@code null} if the timeout expires
307307
* @throws JmsException checked JMSException converted to unchecked
308308
*/
309309
@Nullable
@@ -317,7 +317,7 @@ void convertAndSend(String destinationName, Object message, MessagePostProcessor
317317
* until the message becomes available or until the timeout value is exceeded.
318318
* @param destinationName the name of the destination to send this message to
319319
* (to be resolved to an actual destination by a DestinationResolver)
320-
* @return the message produced for the consumer or {@code null} if the timeout expires.
320+
* @return the message produced for the consumer, or {@code null} if the timeout expires
321321
* @throws JmsException checked JMSException converted to unchecked
322322
*/
323323
@Nullable
@@ -332,7 +332,7 @@ void convertAndSend(String destinationName, Object message, MessagePostProcessor
332332
* <p>This will only work with a default destination specified!
333333
* @param messageSelector the JMS message selector expression (or {@code null} if none).
334334
* See the JMS specification for a detailed definition of selector expressions.
335-
* @return the message produced for the consumer or {@code null} if the timeout expires.
335+
* @return the message produced for the consumer, or {@code null} if the timeout expires
336336
* @throws JmsException checked JMSException converted to unchecked
337337
*/
338338
@Nullable
@@ -347,7 +347,7 @@ void convertAndSend(String destinationName, Object message, MessagePostProcessor
347347
* @param destination the destination to receive a message from
348348
* @param messageSelector the JMS message selector expression (or {@code null} if none).
349349
* See the JMS specification for a detailed definition of selector expressions.
350-
* @return the message produced for the consumer or {@code null} if the timeout expires.
350+
* @return the message produced for the consumer, or {@code null} if the timeout expires
351351
* @throws JmsException checked JMSException converted to unchecked
352352
*/
353353
@Nullable
@@ -363,7 +363,7 @@ void convertAndSend(String destinationName, Object message, MessagePostProcessor
363363
* (to be resolved to an actual destination by a DestinationResolver)
364364
* @param messageSelector the JMS message selector expression (or {@code null} if none).
365365
* See the JMS specification for a detailed definition of selector expressions.
366-
* @return the message produced for the consumer or {@code null} if the timeout expires.
366+
* @return the message produced for the consumer, or {@code null} if the timeout expires
367367
* @throws JmsException checked JMSException converted to unchecked
368368
*/
369369
@Nullable

Diff for: spring-web/src/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpRequest.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 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.
@@ -39,11 +39,10 @@
3939
import org.springframework.core.io.buffer.DataBufferFactory;
4040
import org.springframework.http.HttpHeaders;
4141
import org.springframework.http.HttpMethod;
42+
import org.springframework.http.MediaType;
4243
import org.springframework.lang.Nullable;
4344
import org.springframework.util.Assert;
4445

45-
import static org.springframework.http.MediaType.ALL_VALUE;
46-
4746
/**
4847
* {@link ClientHttpRequest} implementation for the Apache HttpComponents HttpClient 5.x.
4948
* @author Martin Tarjányi
@@ -123,16 +122,14 @@ public Mono<Void> setComplete() {
123122
@Override
124123
protected void applyHeaders() {
125124
HttpHeaders headers = getHeaders();
126-
127125
headers.entrySet()
128126
.stream()
129127
.filter(entry -> !HttpHeaders.CONTENT_LENGTH.equals(entry.getKey()))
130128
.forEach(entry -> entry.getValue().forEach(v -> this.httpRequest.addHeader(entry.getKey(), v)));
131129

132130
if (!this.httpRequest.containsHeader(HttpHeaders.ACCEPT)) {
133-
this.httpRequest.addHeader(HttpHeaders.ACCEPT, ALL_VALUE);
131+
this.httpRequest.addHeader(HttpHeaders.ACCEPT, MediaType.ALL_VALUE);
134132
}
135-
136133
this.contentLength = headers.getContentLength();
137134
}
138135

@@ -143,7 +140,6 @@ protected void applyCookies() {
143140
}
144141

145142
CookieStore cookieStore = this.context.getCookieStore();
146-
147143
getCookies().values()
148144
.stream()
149145
.flatMap(Collection::stream)

Diff for: spring-webmvc/src/main/java/org/springframework/web/servlet/support/AbstractFlashMapManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2024 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.
@@ -221,7 +221,7 @@ public final void saveOutputFlashMap(FlashMap flashMap, HttpServletRequest reque
221221

222222
@Nullable
223223
private String decodeAndNormalizePath(@Nullable String path, HttpServletRequest request) {
224-
if (path != null && !path.isEmpty()) {
224+
if (StringUtils.hasLength(path)) {
225225
path = getUrlPathHelper().decodeRequestString(request, path);
226226
if (path.charAt(0) != '/') {
227227
String requestUri = getUrlPathHelper().getRequestUri(request);

0 commit comments

Comments
 (0)