Skip to content

Commit bf08e0c

Browse files
committed
Polishing
1 parent 9202c0a commit bf08e0c

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed

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.
@@ -124,10 +124,16 @@ public AspectMetadata(Class<?> aspectClass, String aspectName) {
124124
* Extract contents from String of form {@code pertarget(contents)}.
125125
*/
126126
private String findPerClause(Class<?> aspectClass) {
127-
String str = aspectClass.getAnnotation(Aspect.class).value();
128-
int beginIndex = str.indexOf('(') + 1;
129-
int endIndex = str.length() - 1;
130-
return str.substring(beginIndex, endIndex);
127+
Aspect ann = aspectClass.getAnnotation(Aspect.class);
128+
if (ann == null) {
129+
return "";
130+
}
131+
String value = ann.value();
132+
int beginIndex = value.indexOf('(');
133+
if (beginIndex < 0) {
134+
return "";
135+
}
136+
return value.substring(beginIndex + 1, value.length() - 1);
131137
}
132138

133139

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

+3-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.
@@ -59,7 +59,7 @@ public MultiValueMapAdapter(Map<K, List<V>> targetMap) {
5959
@Nullable
6060
public V getFirst(K key) {
6161
List<V> values = this.targetMap.get(key);
62-
return (values != null && !values.isEmpty() ? values.get(0) : null);
62+
return (!CollectionUtils.isEmpty(values) ? values.get(0) : null);
6363
}
6464

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

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

+2-2
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.
@@ -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
*

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-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.
@@ -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();

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

spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessageSendingTemplate.java

+2-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.
@@ -168,8 +168,7 @@ protected Message<?> doConvert(Object payload, @Nullable Map<String, Object> hea
168168

169169
Map<String, Object> headersToUse = processHeadersToSend(headers);
170170
if (headersToUse != null) {
171-
messageHeaders = (headersToUse instanceof MessageHeaders _messageHeaders ?
172-
_messageHeaders : new MessageHeaders(headersToUse));
171+
messageHeaders = (headersToUse instanceof MessageHeaders mh ? mh : new MessageHeaders(headersToUse));
173172
}
174173

175174
MessageConverter converter = getMessageConverter();

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.
@@ -220,7 +220,7 @@ public final void saveOutputFlashMap(FlashMap flashMap, HttpServletRequest reque
220220

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

0 commit comments

Comments
 (0)