diff --git a/spring-integration-core/src/main/java/org/springframework/integration/filter/MessageFilter.java b/spring-integration-core/src/main/java/org/springframework/integration/filter/MessageFilter.java index b6bcef2312a..33b9fb9fad8 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/filter/MessageFilter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/filter/MessageFilter.java @@ -16,6 +16,8 @@ package org.springframework.integration.filter; +import org.jspecify.annotations.Nullable; + import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.context.Lifecycle; @@ -53,9 +55,9 @@ public class MessageFilter extends AbstractReplyProducingPostProcessingMessageHa private boolean throwExceptionOnRejection; - private MessageChannel discardChannel; + private @Nullable MessageChannel discardChannel; - private String discardChannelName; + private @Nullable String discardChannelName; /** * Create a MessageFilter that will delegate to the given {@link MessageSelector}. @@ -111,7 +113,7 @@ public void setDiscardWithinAdvice(boolean discardWithinAdvice) { } @Override - public MessageChannel getDiscardChannel() { + public @Nullable MessageChannel getDiscardChannel() { String channelName = this.discardChannelName; if (channelName != null) { this.discardChannel = getChannelResolver().resolveDestination(channelName); @@ -134,15 +136,13 @@ public IntegrationPatternType getIntegrationPatternType() { protected void doInit() { Assert.state(!(this.discardChannelName != null && this.discardChannel != null), "'discardChannelName' and 'discardChannel' are mutually exclusive."); - if (this.selector instanceof AbstractMessageProcessingSelector) { + if (this.selector instanceof AbstractMessageProcessingSelector abstractMessageProcessingSelector) { ConversionService conversionService = getConversionService(); - if (conversionService != null) { - ((AbstractMessageProcessingSelector) this.selector).setConversionService(conversionService); - } + abstractMessageProcessingSelector.setConversionService(conversionService); } BeanFactory beanFactory = getBeanFactory(); - if (this.selector instanceof BeanFactoryAware && beanFactory != null) { - ((BeanFactoryAware) this.selector).setBeanFactory(beanFactory); + if (this.selector instanceof BeanFactoryAware beanFactoryAware) { + beanFactoryAware.setBeanFactory(beanFactory); } } @@ -166,7 +166,7 @@ public boolean isRunning() { } @Override - protected Object doHandleRequestMessage(Message message) { + protected @Nullable Object doHandleRequestMessage(Message message) { if (this.selector.accept(message)) { return message; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/filter/MethodInvokingSelector.java b/spring-integration-core/src/main/java/org/springframework/integration/filter/MethodInvokingSelector.java index 17a90735bc5..945dac463a5 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/filter/MethodInvokingSelector.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/filter/MethodInvokingSelector.java @@ -34,7 +34,7 @@ public class MethodInvokingSelector extends AbstractMessageProcessingSelector { public MethodInvokingSelector(Object object, Method method) { - super(new MethodInvokingMessageProcessor(object, method)); + super(new MethodInvokingMessageProcessor<>(object, method)); Class returnType = method.getReturnType(); Assert.isTrue(boolean.class.isAssignableFrom(returnType) || Boolean.class.isAssignableFrom(returnType), @@ -42,13 +42,13 @@ public MethodInvokingSelector(Object object, Method method) { } public MethodInvokingSelector(Object object, String methodName) { - super(new MethodInvokingMessageProcessor(object, methodName)); + super(new MethodInvokingMessageProcessor<>(object, methodName)); } @SuppressWarnings("unchecked") public MethodInvokingSelector(Object object) { super(object instanceof MessageProcessor ? (MessageProcessor) object : - new MethodInvokingMessageProcessor(object, Filter.class)); + new MethodInvokingMessageProcessor<>(object, Filter.class)); } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/filter/package-info.java b/spring-integration-core/src/main/java/org/springframework/integration/filter/package-info.java index 2b1d4190e67..16f44b4707d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/filter/package-info.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/filter/package-info.java @@ -1,4 +1,5 @@ /** * Provides classes supporting the filter pattern. */ +@org.jspecify.annotations.NullMarked package org.springframework.integration.filter; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/history/HistoryWritingMessagePostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/history/HistoryWritingMessagePostProcessor.java index 38d28b47c85..6ea980605c3 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/history/HistoryWritingMessagePostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/history/HistoryWritingMessagePostProcessor.java @@ -16,6 +16,8 @@ package org.springframework.integration.history; +import org.jspecify.annotations.Nullable; + import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.MessageBuilderFactory; import org.springframework.integration.support.management.TrackableComponent; @@ -29,7 +31,7 @@ */ public class HistoryWritingMessagePostProcessor implements MessagePostProcessor { - private volatile TrackableComponent trackableComponent; + private volatile @Nullable TrackableComponent trackableComponent; private volatile boolean shouldTrack; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistoryConfigurer.java b/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistoryConfigurer.java index 9bd9ab8eec8..25e10276676 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistoryConfigurer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistoryConfigurer.java @@ -63,6 +63,7 @@ public class MessageHistoryConfigurer implements ManageableSmartLifecycle, BeanF private String[] componentNamePatterns = {"*"}; + @SuppressWarnings("NullAway.Init") private ListableBeanFactory beanFactory; private boolean autoStartup = true; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/history/package-info.java b/spring-integration-core/src/main/java/org/springframework/integration/history/package-info.java index bb452b4b98b..66452fd5155 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/history/package-info.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/history/package-info.java @@ -1,4 +1,5 @@ /** * Provides classes supporting the capture of message history. */ +@org.jspecify.annotations.NullMarked package org.springframework.integration.history;