Perform NullAway build-time checks in spring-messaging

See gh-32475
This commit is contained in:
Sébastien Deleuze 2024-03-25 12:30:03 +01:00
parent f421f38e24
commit 7c009ccc1f
9 changed files with 11 additions and 2 deletions

View File

@ -118,7 +118,7 @@ tasks.withType(JavaCompile).configureEach {
disableAllChecks = true
option("NullAway:CustomContractAnnotations", "org.springframework.lang.Contract")
option("NullAway:AnnotatedPackages", "org.springframework.core,org.springframework.expression," +
"org.springframework.web,org.springframework.jms")
"org.springframework.web,org.springframework.jms,org.springframework.messaging")
option("NullAway:UnannotatedSubPackages", "org.springframework.instrument,org.springframework.context.index," +
"org.springframework.asm,org.springframework.cglib,org.springframework.objenesis," +
"org.springframework.javapoet,org.springframework.aot.nativex.substitution")

View File

@ -196,7 +196,8 @@ public class HandlerMethod extends AnnotatedMethod {
@Override
public boolean equals(@Nullable Object other) {
return (this == other || (super.equals(other) && this.bean.equals(((HandlerMethod) other).bean)));
return (this == other || (super.equals(other) && other instanceof HandlerMethod otherMethod
&& this.bean.equals(otherMethod.bean)));
}
@Override

View File

@ -305,6 +305,7 @@ public class MessageMappingMessageHandler extends AbstractMethodMessageHandler<C
* @param destinations the destinations
* @return new array with the processed destinations or the same array
*/
@SuppressWarnings("NullAway")
protected String[] processDestinations(String[] destinations) {
if (this.valueResolver != null) {
destinations = Arrays.stream(destinations)

View File

@ -522,6 +522,7 @@ 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);

View File

@ -505,6 +505,7 @@ public abstract class AbstractMethodMessageHandler<T>
@Nullable
protected abstract RouteMatcher.Route getDestination(Message<?> message);
@SuppressWarnings("NullAway")
private void addMatchesToCollection(
Collection<T> mappingsToCheck, Message<?> message, List<Match<T>> matches) {

View File

@ -130,6 +130,7 @@ public class StompDecoder {
* Decode a single STOMP frame from the given {@code byteBuffer} into a {@link Message}.
*/
@Nullable
@SuppressWarnings("NullAway")
private Message<byte[]> decodeMessage(ByteBuffer byteBuffer, @Nullable MultiValueMap<String, String> headers) {
Message<byte[]> decodedMessage = null;
skipEol(byteBuffer);

View File

@ -237,6 +237,7 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
return (SimpMessageType.HEARTBEAT == getMessageType());
}
@SuppressWarnings("NullAway")
public long[] getHeartbeat() {
String rawValue = getFirstNativeHeader(STOMP_HEARTBEAT_HEADER);
int pos = (rawValue != null ? rawValue.indexOf(',') : -1);

View File

@ -278,6 +278,7 @@ public class StompHeaders implements MultiValueMap<String, String>, Serializable
* Get the heartbeat header.
*/
@Nullable
@SuppressWarnings("NullAway")
public long[] getHeartbeat() {
String rawValue = getFirst(HEARTBEAT);
int pos = (rawValue != null ? rawValue.indexOf(',') : -1);
@ -514,6 +515,7 @@ public class StompHeaders implements MultiValueMap<String, String>, Serializable
}
@Override
@Nullable
public List<String> get(Object key) {
return this.headers.get(key);
}

View File

@ -645,6 +645,7 @@ public class MessageHeaderAccessor {
return super.getRawHeaders();
}
@SuppressWarnings("NullAway")
public void setImmutable() {
if (!this.mutable) {
return;