Browse Source

Polishing

pull/32864/head
Juergen Hoeller 2 years ago
parent
commit
bf08e0c1b4
  1. 16
      spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java
  2. 6
      spring-core/src/main/java/org/springframework/util/MultiValueMapAdapter.java
  3. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java
  4. 7
      spring-jms/src/main/java/org/springframework/jms/core/JmsMessagingTemplate.java
  5. 14
      spring-jms/src/main/java/org/springframework/jms/core/JmsOperations.java
  6. 5
      spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessageSendingTemplate.java
  7. 4
      spring-webmvc/src/main/java/org/springframework/web/servlet/support/AbstractFlashMapManager.java

16
spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -124,10 +124,16 @@ public class AspectMetadata implements Serializable { @@ -124,10 +124,16 @@ public class AspectMetadata implements Serializable {
* Extract contents from String of form {@code pertarget(contents)}.
*/
private String findPerClause(Class<?> aspectClass) {
String str = aspectClass.getAnnotation(Aspect.class).value();
int beginIndex = str.indexOf('(') + 1;
int endIndex = str.length() - 1;
return str.substring(beginIndex, endIndex);
Aspect ann = aspectClass.getAnnotation(Aspect.class);
if (ann == null) {
return "";
}
String value = ann.value();
int beginIndex = value.indexOf('(');
if (beginIndex < 0) {
return "";
}
return value.substring(beginIndex + 1, value.length() - 1);
}

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -59,7 +59,7 @@ public class MultiValueMapAdapter<K, V> implements MultiValueMap<K, V>, Serializ @@ -59,7 +59,7 @@ public class MultiValueMapAdapter<K, V> implements MultiValueMap<K, V>, Serializ
@Nullable
public V getFirst(K key) {
List<V> values = this.targetMap.get(key);
return (values != null && !values.isEmpty() ? values.get(0) : null);
return (!CollectionUtils.isEmpty(values) ? values.get(0) : null);
}
@Override
@ -95,7 +95,7 @@ public class MultiValueMapAdapter<K, V> implements MultiValueMap<K, V>, Serializ @@ -95,7 +95,7 @@ public class MultiValueMapAdapter<K, V> implements MultiValueMap<K, V>, Serializ
public Map<K, V> toSingleValueMap() {
Map<K, V> singleValueMap = CollectionUtils.newLinkedHashMap(this.targetMap.size());
this.targetMap.forEach((key, values) -> {
if (values != null && !values.isEmpty()) {
if (!CollectionUtils.isEmpty(values)) {
singleValueMap.put(key, values.get(0));
}
});

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -32,7 +32,7 @@ import org.springframework.lang.Nullable; @@ -32,7 +32,7 @@ import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
/**
* The default implementation of Spring's {@link SqlRowSet} interface, wrapping a
* The common implementation of Spring's {@link SqlRowSet} interface, wrapping a
* {@link java.sql.ResultSet}, catching any {@link SQLException SQLExceptions} and
* translating them to a corresponding Spring {@link InvalidResultSetAccessException}.
*

7
spring-jms/src/main/java/org/springframework/jms/core/JmsMessagingTemplate.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -189,11 +189,6 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination> @@ -189,11 +189,6 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
}
}
@Override
public void convertAndSend(Object payload) throws MessagingException {
convertAndSend(payload, null);
}
@Override
public void convertAndSend(Object payload, @Nullable MessagePostProcessor postProcessor) throws MessagingException {
Destination defaultDestination = getDefaultDestination();

14
spring-jms/src/main/java/org/springframework/jms/core/JmsOperations.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2024 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.
@ -290,7 +290,7 @@ public interface JmsOperations { @@ -290,7 +290,7 @@ public interface JmsOperations {
* <p>This method should be used carefully, since it will block the thread
* until the message becomes available or until the timeout value is exceeded.
* <p>This will only work with a default destination specified!
* @return the message produced for the consumer or {@code null} if the timeout expires.
* @return the message produced for the consumer, or {@code null} if the timeout expires
* @throws JmsException checked JMSException converted to unchecked
*/
@Nullable
@ -303,7 +303,7 @@ public interface JmsOperations { @@ -303,7 +303,7 @@ public interface JmsOperations {
* <p>This method should be used carefully, since it will block the thread
* until the message becomes available or until the timeout value is exceeded.
* @param destination the destination to receive a message from
* @return the message produced for the consumer or {@code null} if the timeout expires.
* @return the message produced for the consumer, or {@code null} if the timeout expires
* @throws JmsException checked JMSException converted to unchecked
*/
@Nullable
@ -317,7 +317,7 @@ public interface JmsOperations { @@ -317,7 +317,7 @@ public interface JmsOperations {
* until the message becomes available or until the timeout value is exceeded.
* @param destinationName the name of the destination to send this message to
* (to be resolved to an actual destination by a DestinationResolver)
* @return the message produced for the consumer or {@code null} if the timeout expires.
* @return the message produced for the consumer, or {@code null} if the timeout expires
* @throws JmsException checked JMSException converted to unchecked
*/
@Nullable
@ -332,7 +332,7 @@ public interface JmsOperations { @@ -332,7 +332,7 @@ public interface JmsOperations {
* <p>This will only work with a default destination specified!
* @param messageSelector the JMS message selector expression (or {@code null} if none).
* See the JMS specification for a detailed definition of selector expressions.
* @return the message produced for the consumer or {@code null} if the timeout expires.
* @return the message produced for the consumer, or {@code null} if the timeout expires
* @throws JmsException checked JMSException converted to unchecked
*/
@Nullable
@ -347,7 +347,7 @@ public interface JmsOperations { @@ -347,7 +347,7 @@ public interface JmsOperations {
* @param destination the destination to receive a message from
* @param messageSelector the JMS message selector expression (or {@code null} if none).
* See the JMS specification for a detailed definition of selector expressions.
* @return the message produced for the consumer or {@code null} if the timeout expires.
* @return the message produced for the consumer, or {@code null} if the timeout expires
* @throws JmsException checked JMSException converted to unchecked
*/
@Nullable
@ -363,7 +363,7 @@ public interface JmsOperations { @@ -363,7 +363,7 @@ public interface JmsOperations {
* (to be resolved to an actual destination by a DestinationResolver)
* @param messageSelector the JMS message selector expression (or {@code null} if none).
* See the JMS specification for a detailed definition of selector expressions.
* @return the message produced for the consumer or {@code null} if the timeout expires.
* @return the message produced for the consumer, or {@code null} if the timeout expires
* @throws JmsException checked JMSException converted to unchecked
*/
@Nullable

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -168,8 +168,7 @@ public abstract class AbstractMessageSendingTemplate<D> implements MessageSendin @@ -168,8 +168,7 @@ public abstract class AbstractMessageSendingTemplate<D> implements MessageSendin
Map<String, Object> headersToUse = processHeadersToSend(headers);
if (headersToUse != null) {
messageHeaders = (headersToUse instanceof MessageHeaders _messageHeaders ?
_messageHeaders : new MessageHeaders(headersToUse));
messageHeaders = (headersToUse instanceof MessageHeaders mh ? mh : new MessageHeaders(headersToUse));
}
MessageConverter converter = getMessageConverter();

4
spring-webmvc/src/main/java/org/springframework/web/servlet/support/AbstractFlashMapManager.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 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.
@ -220,7 +220,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager { @@ -220,7 +220,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
@Nullable
private String decodeAndNormalizePath(@Nullable String path, HttpServletRequest request) {
if (path != null && !path.isEmpty()) {
if (StringUtils.hasLength(path)) {
path = getUrlPathHelper().decodeRequestString(request, path);
if (path.charAt(0) != '/') {
String requestUri = getUrlPathHelper().getRequestUri(request);

Loading…
Cancel
Save