Skip to content

Commit 7c009cc

Browse files
committed
Perform NullAway build-time checks in spring-messaging
See gh-32475
1 parent f421f38 commit 7c009cc

File tree

9 files changed

+11
-2
lines changed

9 files changed

+11
-2
lines changed

gradle/spring-module.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ tasks.withType(JavaCompile).configureEach {
118118
disableAllChecks = true
119119
option("NullAway:CustomContractAnnotations", "org.springframework.lang.Contract")
120120
option("NullAway:AnnotatedPackages", "org.springframework.core,org.springframework.expression," +
121-
"org.springframework.web,org.springframework.jms")
121+
"org.springframework.web,org.springframework.jms,org.springframework.messaging")
122122
option("NullAway:UnannotatedSubPackages", "org.springframework.instrument,org.springframework.context.index," +
123123
"org.springframework.asm,org.springframework.cglib,org.springframework.objenesis," +
124124
"org.springframework.javapoet,org.springframework.aot.nativex.substitution")

spring-messaging/src/main/java/org/springframework/messaging/handler/HandlerMethod.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ public String getShortLogMessage() {
196196

197197
@Override
198198
public boolean equals(@Nullable Object other) {
199-
return (this == other || (super.equals(other) && this.bean.equals(((HandlerMethod) other).bean)));
199+
return (this == other || (super.equals(other) && other instanceof HandlerMethod otherMethod
200+
&& this.bean.equals(otherMethod.bean)));
200201
}
201202

202203
@Override

spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/reactive/MessageMappingMessageHandler.java

+1
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ protected CompositeMessageCondition getCondition(AnnotatedElement element) {
305305
* @param destinations the destinations
306306
* @return new array with the processed destinations or the same array
307307
*/
308+
@SuppressWarnings("NullAway")
308309
protected String[] processDestinations(String[] destinations) {
309310
if (this.valueResolver != null) {
310311
destinations = Arrays.stream(destinations)

spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractMethodMessageHandler.java

+1
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ protected void handleMessageInternal(Message<?> message, String lookupDestinatio
522522
handleMatch(bestMatch.mapping, bestMatch.handlerMethod, lookupDestination, message);
523523
}
524524

525+
@SuppressWarnings("NullAway")
525526
private void addMatchesToCollection(Collection<T> mappingsToCheck, Message<?> message, List<Match> matches) {
526527
for (T mapping : mappingsToCheck) {
527528
T match = getMatchingMapping(mapping, message);

spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractMethodMessageHandler.java

+1
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ private Match<T> getHandlerMethod(Message<?> message) {
505505
@Nullable
506506
protected abstract RouteMatcher.Route getDestination(Message<?> message);
507507

508+
@SuppressWarnings("NullAway")
508509
private void addMatchesToCollection(
509510
Collection<T> mappingsToCheck, Message<?> message, List<Match<T>> matches) {
510511

spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public List<Message<byte[]>> decode(ByteBuffer byteBuffer,
130130
* Decode a single STOMP frame from the given {@code byteBuffer} into a {@link Message}.
131131
*/
132132
@Nullable
133+
@SuppressWarnings("NullAway")
133134
private Message<byte[]> decodeMessage(ByteBuffer byteBuffer, @Nullable MultiValueMap<String, String> headers) {
134135
Message<byte[]> decodedMessage = null;
135136
skipEol(byteBuffer);

spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaderAccessor.java

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ public boolean isHeartbeat() {
237237
return (SimpMessageType.HEARTBEAT == getMessageType());
238238
}
239239

240+
@SuppressWarnings("NullAway")
240241
public long[] getHeartbeat() {
241242
String rawValue = getFirstNativeHeader(STOMP_HEARTBEAT_HEADER);
242243
int pos = (rawValue != null ? rawValue.indexOf(',') : -1);

spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaders.java

+2
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ public void setHeartbeat(@Nullable long[] heartbeat) {
278278
* Get the heartbeat header.
279279
*/
280280
@Nullable
281+
@SuppressWarnings("NullAway")
281282
public long[] getHeartbeat() {
282283
String rawValue = getFirst(HEARTBEAT);
283284
int pos = (rawValue != null ? rawValue.indexOf(',') : -1);
@@ -514,6 +515,7 @@ public boolean containsValue(Object value) {
514515
}
515516

516517
@Override
518+
@Nullable
517519
public List<String> get(Object key) {
518520
return this.headers.get(key);
519521
}

spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java

+1
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ public Map<String, Object> getRawHeaders() {
645645
return super.getRawHeaders();
646646
}
647647

648+
@SuppressWarnings("NullAway")
648649
public void setImmutable() {
649650
if (!this.mutable) {
650651
return;

0 commit comments

Comments
 (0)