Skip to content

Add NullaWay to package-info for o.s.i.config package #10208

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class AggregatingMessageHandler extends AbstractCorrelatingMessageHandler
private volatile boolean expireGroupsUponCompletion = false;

public AggregatingMessageHandler(MessageGroupProcessor processor, MessageGroupStore store,
CorrelationStrategy correlationStrategy, ReleaseStrategy releaseStrategy) {
@Nullable CorrelationStrategy correlationStrategy, @Nullable ReleaseStrategy releaseStrategy) {

super(processor, store, correlationStrategy, releaseStrategy);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public abstract class AbstractEvaluationContextFactoryBean implements Applicatio

private TypeConverter typeConverter = new StandardTypeConverter();

@SuppressWarnings("NullAway.Init")
private ApplicationContext applicationContext;

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -133,17 +134,21 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation

protected final List<String> messageHandlerAttributes = new ArrayList<>(); // NOSONAR

protected final Class<T> annotationType; // NOSONAR
protected final Class<T> annotationType;

@SuppressWarnings("NullAway.Init")
private ConfigurableListableBeanFactory beanFactory;

@SuppressWarnings("NullAway.Init")
private BeanDefinitionRegistry definitionRegistry;

@SuppressWarnings("NullAway.Init")
private ConversionService conversionService;

@SuppressWarnings("NullAway.Init")
private volatile DestinationResolver<MessageChannel> channelResolver;

@SuppressWarnings(UNCHECKED)
@SuppressWarnings("NullAway")
public AbstractMethodAnnotationPostProcessor() {
this.messageHandlerAttributes.add(SEND_TIMEOUT_ATTRIBUTE);
this.annotationType =
Expand Down Expand Up @@ -190,7 +195,7 @@ public void processBeanDefinition(String beanName, AnnotatedBeanDefinition beanD
BeanDefinition handlerBeanDefinition =
resolveHandlerBeanDefinition(beanName, beanDefinition, handlerBeanType, annotations);
MergedAnnotations mergedAnnotations =
beanDefinition.getFactoryMethodMetadata().getAnnotations(); // NOSONAR
Objects.requireNonNull(beanDefinition.getFactoryMethodMetadata()).getAnnotations();

if (handlerBeanDefinition != null) {
if (!handlerBeanDefinition.equals(beanDefinition)) {
Expand Down Expand Up @@ -410,7 +415,7 @@ protected BeanDefinition resolveHandlerBeanDefinition(String beanName, Annotated
if (FactoryBean.class.isAssignableFrom(classToCheck)) {
classToCheck = this.beanFactory.getType(beanName);
}

Assert.state(classToCheck != null, "No handler bean found for " + beanName);
if (isClassIn(classToCheck, AbstractMessageProducingHandler.class, AbstractMessageRouter.class)) {
checkMessageHandlerAttributes(beanName, annotations);
return beanDefinition;
Expand Down Expand Up @@ -482,7 +487,7 @@ private MessageHandler annotated(Method method, MessageHandler handlerArg) {
&& !AnnotatedElementUtils.isAnnotated(method, Bean.class.getName())) {

String[] interceptors =
AnnotationUtils.getAnnotation(method, IdempotentReceiver.class).value(); // NOSONAR never null
Objects.requireNonNull(AnnotationUtils.getAnnotation(method, IdempotentReceiver.class)).value();
for (String interceptor : interceptors) {
DefaultBeanFactoryPointcutAdvisor advisor = new DefaultBeanFactoryPointcutAdvisor();
advisor.setAdviceBeanName(interceptor);
Expand Down Expand Up @@ -531,7 +536,7 @@ private MessageHandler adviceChain(String beanName, List<Annotation> annotations
return handler;
}

protected List<Advice> extractAdviceChain(String beanName, List<Annotation> annotations) {
protected @Nullable List<Advice> extractAdviceChain(String beanName, List<Annotation> annotations) {
List<Advice> adviceChain = null;
String[] adviceChainNames = MessagingAnnotationUtils.resolveAttribute(annotations, ADVICE_CHAIN_ATTRIBUTE,
String[].class);
Expand Down Expand Up @@ -564,7 +569,7 @@ else if (adviceChainBean instanceof Collection) {
return adviceChain;
}

protected AbstractEndpoint createEndpoint(MessageHandler handler, @SuppressWarnings("unused") Method method,
protected @Nullable AbstractEndpoint createEndpoint(MessageHandler handler, @SuppressWarnings("unused") Method method,
List<Annotation> annotations) {

AbstractEndpoint endpoint = null;
Expand Down Expand Up @@ -622,7 +627,7 @@ else if (inputChannel instanceof PollableChannel) {
}

private ReactiveStreamsConsumer reactiveStreamsConsumer(MessageChannel channel, MessageHandler handler,
Reactive reactive) {
@Nullable Reactive reactive) {

ReactiveStreamsConsumer reactiveStreamsConsumer;
if (handler instanceof ReactiveMessageHandlerAdapter reactiveMessageHandlerAdapter) {
Expand All @@ -646,13 +651,13 @@ private ReactiveStreamsConsumer reactiveStreamsConsumer(MessageChannel channel,
return reactiveStreamsConsumer;
}

private PollingConsumer pollingConsumer(MessageChannel inputChannel, MessageHandler handler, Poller poller) {
private PollingConsumer pollingConsumer(MessageChannel inputChannel, MessageHandler handler, @Nullable Poller poller) {
PollingConsumer pollingConsumer = new PollingConsumer((PollableChannel) inputChannel, handler);
configurePollingEndpoint(pollingConsumer, poller);
return pollingConsumer;
}

protected void configurePollingEndpoint(AbstractPollingEndpoint pollingEndpoint, Poller poller) {
protected void configurePollingEndpoint(AbstractPollingEndpoint pollingEndpoint, @Nullable Poller poller) {
PollerMetadata pollerMetadata;
if (poller != null) {
String ref = poller.value();
Expand Down Expand Up @@ -704,8 +709,9 @@ protected void configurePollingEndpoint(AbstractPollingEndpoint pollingEndpoint,
}

private PollerMetadata configurePoller(AbstractPollingEndpoint pollingEndpoint, String triggerRef,
String executorRef, String fixedDelayValue, String fixedRateValue, String maxMessagesPerPollValue,
String cron, String errorChannel, String receiveTimeout) {
String executorRef, @Nullable String fixedDelayValue, @Nullable String fixedRateValue,
@Nullable String maxMessagesPerPollValue, @Nullable String cron, @Nullable String errorChannel,
@Nullable String receiveTimeout) {

PollerMetadata pollerMetadata;
pollerMetadata = new PollerMetadata();
Expand Down Expand Up @@ -736,7 +742,7 @@ else if (pollingEndpoint instanceof SourcePollingChannelAdapter) {
return pollerMetadata;
}

private void trigger(String triggerRef, String fixedDelayValue, String fixedRateValue, String cron,
private void trigger(String triggerRef, @Nullable String fixedDelayValue, @Nullable String fixedRateValue, @Nullable String cron,
PollerMetadata pollerMetadata) {

Trigger trigger = null;
Expand Down Expand Up @@ -815,7 +821,7 @@ protected boolean resolveAttributeToBoolean(String attribute) {
return Boolean.parseBoolean(this.beanFactory.resolveEmbeddedValue(attribute));
}

protected static BeanDefinition buildLambdaMessageProcessor(ResolvableType beanType,
protected static @Nullable BeanDefinition buildLambdaMessageProcessor(ResolvableType beanType,
AnnotatedBeanDefinition beanDefinition) {

Class<?> beanClass = beanType.toClass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
package org.springframework.integration.config;

import java.util.List;
import java.util.Objects;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import org.aopalliance.aop.Advice;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;

import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.AopProxyUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
Expand Down Expand Up @@ -71,29 +72,34 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageH

private final Lock initializationMonitor = new ReentrantLock();

@SuppressWarnings("NullAway.Init")
private BeanFactory beanFactory;

@SuppressWarnings("NullAway.Init")
private H handler;

private MessageChannel outputChannel;
private @Nullable MessageChannel outputChannel;

private String outputChannelName;
private @Nullable String outputChannelName;

private Integer order;
private @Nullable Integer order;

private List<Advice> adviceChain;
private @Nullable List<Advice> adviceChain;

private String componentName;
private @Nullable String componentName;

@SuppressWarnings("NullAway.Init")
private ApplicationContext applicationContext;

@SuppressWarnings("NullAway.Init")
private String beanName;

@SuppressWarnings("NullAway.Init")
private ApplicationEventPublisher applicationEventPublisher;

private DestinationResolver<MessageChannel> channelResolver;
private @Nullable DestinationResolver<MessageChannel> channelResolver;

private Boolean async;
private @Nullable Boolean async;

private boolean initialized;

Expand Down Expand Up @@ -190,18 +196,14 @@ public void setComponentName(String componentName) {
public H getObject() {
if (this.handler == null) {
this.handler = createHandlerInternal();
Assert.notNull(this.handler, "failed to create MessageHandler");
}
return this.handler;
}

protected final H createHandlerInternal() {
this.initializationMonitor.lock();
try {
if (this.initialized) {
// There was a problem when this method was called already
return null;
}
Assert.state(!this.initialized, "FactoryBean already initialized");
this.handler = createHandler();
JavaUtils.INSTANCE
.acceptIfCondition(this.handler instanceof ApplicationContextAware && this.applicationContext != null,
Expand Down Expand Up @@ -313,12 +315,7 @@ public boolean isSingleton() {
}

private static Object extractTarget(Object object) {
if (!(object instanceof Advised)) {
return object;
}
else {
return extractTarget(AopProxyUtils.getSingletonTarget(object));
}
return Objects.requireNonNullElse(AopProxyUtils.getSingletonTarget(object), object);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
package org.springframework.integration.config;

import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

import org.jspecify.annotations.Nullable;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
Expand Down Expand Up @@ -48,16 +51,22 @@ public abstract class AbstractStandardMessageHandlerFactoryBean

private static final Set<MessageHandler> REFERENCED_REPLY_PRODUCERS = new HashSet<>();

@SuppressWarnings("NullAway.Init")
private Boolean requiresReply;

@SuppressWarnings("NullAway.Init")
private Object targetObject;

@SuppressWarnings("NullAway.Init")
private String targetMethodName;

@SuppressWarnings("NullAway.Init")
private Expression expression;

@SuppressWarnings("NullAway.Init")
private Long sendTimeout;

@SuppressWarnings("NullAway.Init")
private MessageHandler replyHandler;

/**
Expand Down Expand Up @@ -135,8 +144,8 @@ else if (targetIsDirectReplyProducingHandler) {
if (logger.isDebugEnabled()) {
logger.debug("Wiring handler (" + this.targetObject + ") directly into endpoint");
}
checkReuse(actualHandler);
postProcessReplyProducer(actualHandler);
checkReuse(Objects.requireNonNull(actualHandler));
postProcessReplyProducer(Objects.requireNonNull(actualHandler));
handler = (MessageHandler) this.targetObject;
}
else {
Expand All @@ -152,7 +161,7 @@ else if (this.expression != null) {
return handler;
}

protected void checkForIllegalTarget(Object targetObject, String targetMethodName) {
protected void checkForIllegalTarget(Object targetObject, @Nullable String targetMethodName) {
if (targetObject instanceof AbstractReplyProducingMessageHandler
&& methodIsHandleMessageOrEmpty(targetMethodName)) {
/*
Expand All @@ -179,7 +188,7 @@ private void checkReuse(AbstractMessageProducingHandler replyHandler) {
* @param targetMethodName the method name of the target object to invoke.
* @return the method invoking {@link MessageHandler} implementation.
*/
protected abstract MessageHandler createMethodInvokingHandler(Object targetObject, String targetMethodName);
protected abstract MessageHandler createMethodInvokingHandler(Object targetObject, @Nullable String targetMethodName);

protected MessageHandler createExpressionEvaluatingHandler(Expression expression) {
throw new UnsupportedOperationException(getClass().getName() + " does not support expressions.");
Expand All @@ -193,7 +202,7 @@ protected MessageHandler createDefaultHandler() {
throw new IllegalArgumentException("Exactly one of the 'targetObject' or 'expression' property is required.");
}

protected boolean methodIsHandleMessageOrEmpty(String targetMethodName) {
protected boolean methodIsHandleMessageOrEmpty(@Nullable String targetMethodName) {
return (!StringUtils.hasText(targetMethodName)
|| "handleMessage".equals(targetMethodName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,53 +56,54 @@
*/
public class AggregatorFactoryBean extends AbstractSimpleMessageHandlerFactoryBean<AggregatingMessageHandler> {

@SuppressWarnings("NullAway.Init")
private Object processorBean;

private String methodName;
private @Nullable String methodName;

private Boolean expireGroupsUponCompletion;
private @Nullable Boolean expireGroupsUponCompletion;

private Long sendTimeout;
private @Nullable Long sendTimeout;

private String outputChannelName;
private @Nullable String outputChannelName;

private LockRegistry<?> lockRegistry;
private @Nullable LockRegistry<?> lockRegistry;

private MessageGroupStore messageStore;
private @Nullable MessageGroupStore messageStore;

private CorrelationStrategy correlationStrategy;
private @Nullable CorrelationStrategy correlationStrategy;

private ReleaseStrategy releaseStrategy;
private @Nullable ReleaseStrategy releaseStrategy;

private Expression groupTimeoutExpression;
private @Nullable Expression groupTimeoutExpression;

private List<Advice> forceReleaseAdviceChain;
private @Nullable List<Advice> forceReleaseAdviceChain;

private TaskScheduler taskScheduler;
private @Nullable TaskScheduler taskScheduler;

private MessageChannel discardChannel;
private @Nullable MessageChannel discardChannel;

private String discardChannelName;
private @Nullable String discardChannelName;

private Boolean sendPartialResultOnExpiry;
private @Nullable Boolean sendPartialResultOnExpiry;

private Boolean discardIndividuallyOnExpiry;
private @Nullable Boolean discardIndividuallyOnExpiry;

private Long minimumTimeoutForEmptyGroups;
private @Nullable Long minimumTimeoutForEmptyGroups;

private Boolean expireGroupsUponTimeout;
private @Nullable Boolean expireGroupsUponTimeout;

private Boolean popSequence;
private @Nullable Boolean popSequence;

private Boolean releaseLockBeforeSend;
private @Nullable Boolean releaseLockBeforeSend;

private Long expireTimeout;
private @Nullable Long expireTimeout;

private Long expireDuration;
private @Nullable Long expireDuration;

private Function<MessageGroup, Map<String, Object>> headersFunction;
private @Nullable Function<MessageGroup, Map<String, Object>> headersFunction;

private BiFunction<Message<?>, String, String> groupConditionSupplier;
private @Nullable BiFunction<Message<?>, String, String> groupConditionSupplier;

public void setProcessorBean(Object processorBean) {
this.processorBean = processorBean;
Expand Down
Loading