Skip to content

Commit feef9f8

Browse files
GH-10083: Apply Nullability to core history and filter packages
Related to: #10083 * Remove explicit type and redundant condition Signed-off-by: Tran Ngoc Nhan <[email protected]>
1 parent 468784e commit feef9f8

File tree

6 files changed

+19
-14
lines changed

6 files changed

+19
-14
lines changed

spring-integration-core/src/main/java/org/springframework/integration/filter/MessageFilter.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.integration.filter;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.beans.factory.BeanFactory;
2022
import org.springframework.beans.factory.BeanFactoryAware;
2123
import org.springframework.context.Lifecycle;
@@ -53,9 +55,9 @@ public class MessageFilter extends AbstractReplyProducingPostProcessingMessageHa
5355

5456
private boolean throwExceptionOnRejection;
5557

56-
private MessageChannel discardChannel;
58+
private @Nullable MessageChannel discardChannel;
5759

58-
private String discardChannelName;
60+
private @Nullable String discardChannelName;
5961

6062
/**
6163
* Create a MessageFilter that will delegate to the given {@link MessageSelector}.
@@ -111,7 +113,7 @@ public void setDiscardWithinAdvice(boolean discardWithinAdvice) {
111113
}
112114

113115
@Override
114-
public MessageChannel getDiscardChannel() {
116+
public @Nullable MessageChannel getDiscardChannel() {
115117
String channelName = this.discardChannelName;
116118
if (channelName != null) {
117119
this.discardChannel = getChannelResolver().resolveDestination(channelName);
@@ -134,15 +136,13 @@ public IntegrationPatternType getIntegrationPatternType() {
134136
protected void doInit() {
135137
Assert.state(!(this.discardChannelName != null && this.discardChannel != null),
136138
"'discardChannelName' and 'discardChannel' are mutually exclusive.");
137-
if (this.selector instanceof AbstractMessageProcessingSelector) {
139+
if (this.selector instanceof AbstractMessageProcessingSelector abstractMessageProcessingSelector) {
138140
ConversionService conversionService = getConversionService();
139-
if (conversionService != null) {
140-
((AbstractMessageProcessingSelector) this.selector).setConversionService(conversionService);
141-
}
141+
abstractMessageProcessingSelector.setConversionService(conversionService);
142142
}
143143
BeanFactory beanFactory = getBeanFactory();
144-
if (this.selector instanceof BeanFactoryAware && beanFactory != null) {
145-
((BeanFactoryAware) this.selector).setBeanFactory(beanFactory);
144+
if (this.selector instanceof BeanFactoryAware beanFactoryAware) {
145+
beanFactoryAware.setBeanFactory(beanFactory);
146146
}
147147
}
148148

@@ -166,7 +166,7 @@ public boolean isRunning() {
166166
}
167167

168168
@Override
169-
protected Object doHandleRequestMessage(Message<?> message) {
169+
protected @Nullable Object doHandleRequestMessage(Message<?> message) {
170170
if (this.selector.accept(message)) {
171171
return message;
172172
}

spring-integration-core/src/main/java/org/springframework/integration/filter/MethodInvokingSelector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@
3434
public class MethodInvokingSelector extends AbstractMessageProcessingSelector {
3535

3636
public MethodInvokingSelector(Object object, Method method) {
37-
super(new MethodInvokingMessageProcessor<Boolean>(object, method));
37+
super(new MethodInvokingMessageProcessor<>(object, method));
3838
Class<?> returnType = method.getReturnType();
3939
Assert.isTrue(boolean.class.isAssignableFrom(returnType)
4040
|| Boolean.class.isAssignableFrom(returnType),
4141
"MethodInvokingSelector method must return a boolean result.");
4242
}
4343

4444
public MethodInvokingSelector(Object object, String methodName) {
45-
super(new MethodInvokingMessageProcessor<Boolean>(object, methodName));
45+
super(new MethodInvokingMessageProcessor<>(object, methodName));
4646
}
4747

4848
@SuppressWarnings("unchecked")
4949
public MethodInvokingSelector(Object object) {
5050
super(object instanceof MessageProcessor<?> ? (MessageProcessor<Boolean>) object :
51-
new MethodInvokingMessageProcessor<Boolean>(object, Filter.class));
51+
new MethodInvokingMessageProcessor<>(object, Filter.class));
5252
}
5353

5454
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/**
22
* Provides classes supporting the filter pattern.
33
*/
4+
@org.jspecify.annotations.NullMarked
45
package org.springframework.integration.filter;

spring-integration-core/src/main/java/org/springframework/integration/history/HistoryWritingMessagePostProcessor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.integration.history;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.integration.support.DefaultMessageBuilderFactory;
2022
import org.springframework.integration.support.MessageBuilderFactory;
2123
import org.springframework.integration.support.management.TrackableComponent;
@@ -29,7 +31,7 @@
2931
*/
3032
public class HistoryWritingMessagePostProcessor implements MessagePostProcessor {
3133

32-
private volatile TrackableComponent trackableComponent;
34+
private volatile @Nullable TrackableComponent trackableComponent;
3335

3436
private volatile boolean shouldTrack;
3537

spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistoryConfigurer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class MessageHistoryConfigurer implements ManageableSmartLifecycle, BeanF
6363

6464
private String[] componentNamePatterns = {"*"};
6565

66+
@SuppressWarnings("NullAway.Init")
6667
private ListableBeanFactory beanFactory;
6768

6869
private boolean autoStartup = true;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/**
22
* Provides classes supporting the capture of message history.
33
*/
4+
@org.jspecify.annotations.NullMarked
45
package org.springframework.integration.history;

0 commit comments

Comments
 (0)