-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
...ion-amqp/src/main/java/org/springframework/integration/amqp/channel/PollableAmqpChannel.java
Outdated
Show resolved
Hide resolved
...tion-core/src/main/java/org/springframework/integration/channel/AbstractExecutorChannel.java
Outdated
Show resolved
Hide resolved
...ation-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java
Outdated
Show resolved
Hide resolved
...ation-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java
Outdated
Show resolved
Hide resolved
...ation-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java
Outdated
Show resolved
Hide resolved
...ore/src/main/java/org/springframework/integration/channel/MessagePublishingErrorHandler.java
Outdated
Show resolved
Hide resolved
spring-integration-core/src/main/java/org/springframework/integration/channel/NullChannel.java
Outdated
Show resolved
Hide resolved
spring-integration-core/src/main/java/org/springframework/integration/channel/NullChannel.java
Outdated
Show resolved
Hide resolved
...tegration-core/src/main/java/org/springframework/integration/channel/PartitionedChannel.java
Outdated
Show resolved
Hide resolved
...tegration-core/src/main/java/org/springframework/integration/core/ErrorMessagePublisher.java
Outdated
Show resolved
Hide resolved
* 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(), |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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))); |
There was a problem hiding this comment.
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
@Nullify
annotations from classes outside the target packages, where the implemented interface or parent class did not mark the method asNullable
."NullAway.Init"
was used for beanName.NOSONAR
comments in touched classes for improved code cleanliness.Nullable
annotations: moved them from above the method declarations to precede the method return type for consistency.