Skip to content

Commit

Permalink
Perform NullAway build-time checks in spring-messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
sdeleuze committed Mar 25, 2024
1 parent f421f38 commit 7c009cc
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle/spring-module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ public String getShortLogMessage() {

@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ protected CompositeMessageCondition getCondition(AnnotatedElement element) {
* @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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ protected void handleMessageInternal(Message<?> message, String lookupDestinatio
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ private Match<T> getHandlerMethod(Message<?> message) {
@Nullable
protected abstract RouteMatcher.Route getDestination(Message<?> message);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public List<Message<byte[]>> decode(ByteBuffer byteBuffer,
* 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public boolean isHeartbeat() {
return (SimpMessageType.HEARTBEAT == getMessageType());
}

@SuppressWarnings("NullAway")
public long[] getHeartbeat() {
String rawValue = getFirstNativeHeader(STOMP_HEARTBEAT_HEADER);
int pos = (rawValue != null ? rawValue.indexOf(',') : -1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ public void setHeartbeat(@Nullable long[] heartbeat) {
* Get the heartbeat header.
*/
@Nullable
@SuppressWarnings("NullAway")
public long[] getHeartbeat() {
String rawValue = getFirst(HEARTBEAT);
int pos = (rawValue != null ? rawValue.indexOf(',') : -1);
Expand Down Expand Up @@ -514,6 +515,7 @@ public boolean containsValue(Object value) {
}

@Override
@Nullable
public List<String> get(Object key) {
return this.headers.get(key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ public Map<String, Object> getRawHeaders() {
return super.getRawHeaders();
}

@SuppressWarnings("NullAway")
public void setImmutable() {
if (!this.mutable) {
return;
Expand Down

0 comments on commit 7c009cc

Please sign in to comment.