Refine null-safety in the spring-messaging module
Closes gh-34158
This commit is contained in:
parent
4fa33dfece
commit
abccba22f1
|
|
@ -514,12 +514,13 @@ public abstract class AbstractMethodMessageHandler<T>
|
|||
handleMatch(bestMatch.mapping, bestMatch.handlerMethod, lookupDestination, message);
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullAway")
|
||||
private void addMatchesToCollection(Collection<T> mappingsToCheck, Message<?> message, List<Match> matches) {
|
||||
for (T mapping : mappingsToCheck) {
|
||||
T match = getMatchingMapping(mapping, message);
|
||||
if (match != null) {
|
||||
matches.add(new Match(match, this.handlerMethods.get(mapping)));
|
||||
HandlerMethod handlerMethod = this.handlerMethods.get(mapping);
|
||||
Assert.state(handlerMethod != null, "HandlerMethod must not be null");
|
||||
matches.add(new Match(match, handlerMethod));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -496,14 +496,15 @@ public abstract class AbstractMethodMessageHandler<T>
|
|||
*/
|
||||
protected abstract RouteMatcher.@Nullable Route getDestination(Message<?> message);
|
||||
|
||||
@SuppressWarnings("NullAway")
|
||||
private void addMatchesToCollection(
|
||||
Collection<T> mappingsToCheck, Message<?> message, List<Match<T>> matches) {
|
||||
|
||||
for (T mapping : mappingsToCheck) {
|
||||
T match = getMatchingMapping(mapping, message);
|
||||
if (match != null) {
|
||||
matches.add(new Match<>(match, this.handlerMethods.get(mapping)));
|
||||
HandlerMethod handlerMethod = this.handlerMethods.get(mapping);
|
||||
Assert.state(handlerMethod != null, "HandlerMethod must not be null");
|
||||
matches.add(new Match<>(match, handlerMethod));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ final class RSocketServiceMethod {
|
|||
return parameters;
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullAway")
|
||||
@SuppressWarnings("NullAway") // Dataflow analysis limitation
|
||||
private static @Nullable String initRoute(
|
||||
Method method, Class<?> containingClass, RSocketStrategies strategies,
|
||||
@Nullable StringValueResolver embeddedValueResolver) {
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ public class StompDecoder {
|
|||
/**
|
||||
* Decode a single STOMP frame from the given {@code byteBuffer} into a {@link Message}.
|
||||
*/
|
||||
@SuppressWarnings("NullAway")
|
||||
@SuppressWarnings("NullAway") // Dataflow analysis limitation
|
||||
private @Nullable Message<byte[]> decodeMessage(ByteBuffer byteBuffer, @Nullable MultiValueMap<String, String> headers) {
|
||||
Message<byte[]> decodedMessage = null;
|
||||
skipEol(byteBuffer);
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
|
|||
return (SimpMessageType.HEARTBEAT == getMessageType());
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullAway")
|
||||
@SuppressWarnings("NullAway") // Dataflow analysis limitation
|
||||
public long[] getHeartbeat() {
|
||||
String rawValue = getFirstNativeHeader(STOMP_HEARTBEAT_HEADER);
|
||||
int pos = (rawValue != null ? rawValue.indexOf(',') : -1);
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ public class StompHeaders implements MultiValueMap<String, String>, Serializable
|
|||
/**
|
||||
* Get the heartbeat header.
|
||||
*/
|
||||
@SuppressWarnings("NullAway")
|
||||
@SuppressWarnings("NullAway") // Dataflow analysis limitation
|
||||
public long @Nullable [] getHeartbeat() {
|
||||
String rawValue = getFirst(HEARTBEAT);
|
||||
int pos = (rawValue != null ? rawValue.indexOf(',') : -1);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
@ -236,7 +237,7 @@ class MethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String getMatchingMapping(String mapping, Message<?> message) {
|
||||
protected @Nullable String getMatchingMapping(String mapping, Message<?> message) {
|
||||
String destination = getLookupDestination(getDestination(message));
|
||||
Assert.notNull(destination, "No destination");
|
||||
return mapping.equals(destination) || this.pathMatcher.match(mapping, destination) ? mapping : null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue