Skip to content

Apply JSpecify Nullify to the Channel and AOT packages #10182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 1, 2025

Conversation

cppwfs
Copy link
Contributor

@cppwfs cppwfs commented Jul 1, 2025

  • Removed @Nullify annotations from classes outside the target packages, where the implemented interface or parent class did not mark the method as Nullable.
  • Note: One "NullAway.Init" was used for beanName.
  • Removed all NOSONAR comments in touched classes for improved code cleanliness.
  • Adjusted placement of existing Nullable annotations: moved them from above the method declarations to precede the method return type for consistency.

@cppwfs cppwfs requested a review from artembilan July 1, 2025 15:45
@artembilan artembilan added this to the 7.0.0-M1 milestone Jul 1, 2025
* In code segments where performance is critical remove null checks and suppress warnings.
* Format code to improve readability
* Cleanup some Nullable's in a couple locations

Continued effort or issue: spring-projects#10083
@@ -392,15 +390,17 @@ private boolean sendWithObservation(Message<?> message, long timeout) {
Message<?> messageToSendInternal = messageToSend;
if (message instanceof ErrorMessage errorMessage) {
messageToSendInternal =
new ErrorMessage(errorMessage.getPayload(),
(errorMessage.getOriginalMessage() != null) ? new ErrorMessage(errorMessage.getPayload(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider to extract errorMessage.getOriginalMessage() into a local variable for some optimization.

@@ -676,7 +677,6 @@ public boolean remove(ChannelInterceptor interceptor) {
}
}

@Nullable
public ChannelInterceptor remove(int index) {
ChannelInterceptor removed = this.interceptors.remove(index);
if (removed != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one has to be removed as well.
That this.interceptors.remove(index) never returns null and may only throw an exception.
The confuse was really around this nullable variable.
If we remove this if altogether, all good.

@@ -65,7 +66,7 @@ public class PartitionedChannel extends AbstractExecutorChannel {
* sent to this channel.
*/
public PartitionedChannel(int partitionCount) {
this(partitionCount, (message) -> message.getHeaders().get(IntegrationMessageHeaderAccessor.CORRELATION_ID));
this(partitionCount, (message) -> Objects.requireNonNull(message.getHeaders().get(IntegrationMessageHeaderAccessor.CORRELATION_ID)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for my bad English, but I think I said:

put everything after an arrow on a new line

Remember 120 symbols per line rule still applies.

* Optimize use of originalMessage in code where performance is critical
* Remove unnecessary check in remove method in AbstractMessageChannel
* Correct formating
@artembilan artembilan merged commit 93c7661 into spring-projects:main Jul 1, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants