Class MessagingException has a private field failedMessage annotated as @Nullable, however some of its constructors, e.g.: https://github.com/spring-projects/spring-framework/blob/b3f5d20ad8ad0585219fecd390030fd810603c33/spring-messaging/src/main/java/org/springframework/messaging/MessagingException.java#L61 do not have the same annotation.

Given that the package is annotated with @NonNullApi, this creates an inconsistency where

Message<?> failedMessage = null;
var messagingException = new MessagingException(failedMessage, "description", cause);

would produce a warning Passing 'null' argument to parameter annotated as @NotNull, but

Message<?> failedMessage = messagingException.getFailedMessage();
var payload = failedMessage.getPayload();

would also produce a warning Method invocation 'getPayload' may produce 'NullPointerException'.

Comment From: snicoll

I think the current status is fine. failedMessage is @Nullable because there is a way to create the object without a message, see the constructor that takes only a description. The intent is that if you call the constructor that defines a message, it should be non-null.