Skip to content

Commit ebec0da

Browse files
GH-10083: Apply Nullability to some core packages
Related to: #10083 This commit applies Nullability to core `routingslip`, `scattergather`, `scheduling`, and `selector` packages Signed-off-by: Tran Ngoc Nhan <[email protected]>
1 parent b844f3e commit ebec0da

File tree

10 files changed

+38
-24
lines changed

10 files changed

+38
-24
lines changed

spring-integration-core/src/main/java/org/springframework/integration/routingslip/ExpressionEvaluatingRoutingSlipRouteStrategy.java

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

1717
package org.springframework.integration.routingslip;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.beans.BeansException;
2022
import org.springframework.beans.factory.BeanFactory;
2123
import org.springframework.beans.factory.BeanFactoryAware;
@@ -69,8 +71,10 @@ public class ExpressionEvaluatingRoutingSlipRouteStrategy
6971

7072
private final Expression expression;
7173

74+
@SuppressWarnings("NullAway.Init")
7275
private EvaluationContext evaluationContext;
7376

77+
@SuppressWarnings("NullAway.Init")
7478
private BeanFactory beanFactory;
7579

7680
public ExpressionEvaluatingRoutingSlipRouteStrategy(String expression) {
@@ -98,7 +102,7 @@ public void afterPropertiesSet() {
98102
}
99103

100104
@Override
101-
public Object getNextPath(Message<?> requestMessage, Object reply) {
105+
public @Nullable Object getNextPath(Message<?> requestMessage, Object reply) {
102106
return this.expression.getValue(this.evaluationContext, new RequestAndReply(requestMessage, reply));
103107
}
104108

spring-integration-core/src/main/java/org/springframework/integration/routingslip/RoutingSlipRouteStrategy.java

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

1717
package org.springframework.integration.routingslip;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.messaging.Message;
2022

2123
/**
@@ -37,6 +39,7 @@ public interface RoutingSlipRouteStrategy {
3739
* object, a {@link Message} or a {@code AbstractIntegrationMessageBuilder}.
3840
* @return a channel name or another {@link RoutingSlipRouteStrategy}.
3941
*/
42+
@Nullable
4043
Object getNextPath(Message<?> requestMessage, Object reply);
4144

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

spring-integration-core/src/main/java/org/springframework/integration/scattergather/ScatterGatherHandler.java

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

1717
package org.springframework.integration.scattergather;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.aop.support.AopUtils;
2022
import org.springframework.beans.factory.BeanFactory;
2123
import org.springframework.beans.factory.BeanInitializationException;
@@ -63,13 +65,15 @@ public class ScatterGatherHandler extends AbstractReplyProducingMessageHandler i
6365

6466
private final MessageHandler gatherer;
6567

68+
@SuppressWarnings("NullAway.Init")
6669
private MessageChannel gatherChannel;
6770

6871
private String errorChannelName = IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME;
6972

73+
@SuppressWarnings("NullAway.Init")
7074
private Long gatherTimeout;
7175

72-
private AbstractEndpoint gatherEndpoint;
76+
private @Nullable AbstractEndpoint gatherEndpoint;
7377

7478
public ScatterGatherHandler(MessageHandler scatterer, MessageHandler gatherer) {
7579
this(new FixedSubscriberChannel(scatterer), gatherer);
@@ -185,7 +189,7 @@ private Message<?> enhanceScatterReplyMessage(Message<?> message) {
185189
}
186190

187191
@Override
188-
protected Object handleRequestMessage(Message<?> requestMessage) {
192+
protected @Nullable Object handleRequestMessage(Message<?> requestMessage) {
189193
MessageHeaders requestMessageHeaders = requestMessage.getHeaders();
190194
PollableChannel gatherResultChannel = new QueueChannel();
191195

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

spring-integration-core/src/main/java/org/springframework/integration/scheduling/PollSkipAdvice.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.aopalliance.intercept.MethodInvocation;
2121
import org.apache.commons.logging.Log;
2222
import org.apache.commons.logging.LogFactory;
23+
import org.jspecify.annotations.Nullable;
2324

2425
/**
2526
* An advice that can be added to a poller's advice chain that determines
@@ -47,7 +48,7 @@ public PollSkipAdvice(PollSkipStrategy strategy) {
4748
}
4849

4950
@Override
50-
public Object invoke(MethodInvocation invocation) throws Throwable {
51+
public @Nullable Object invoke(MethodInvocation invocation) throws Throwable {
5152
if ("call".equals(invocation.getMethod().getName()) && this.pollSkipStrategy.skipPoll()) {
5253
if (LOGGER.isDebugEnabled()) {
5354
LOGGER.debug("Skipping poll because "
@@ -56,9 +57,7 @@ public Object invoke(MethodInvocation invocation) throws Throwable {
5657
}
5758
return null;
5859
}
59-
else {
60-
return invocation.proceed();
61-
}
60+
return invocation.proceed();
6261
}
6362

6463
private static final class DefaultPollSkipStrategy implements PollSkipStrategy {

spring-integration-core/src/main/java/org/springframework/integration/scheduling/PollerMetadata.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.concurrent.Executor;
2121

2222
import org.aopalliance.aop.Advice;
23+
import org.jspecify.annotations.Nullable;
2324

2425
import org.springframework.beans.factory.BeanFactory;
2526
import org.springframework.integration.transaction.TransactionSynchronizationFactory;
@@ -56,39 +57,39 @@ public class PollerMetadata {
5657
*/
5758
public static final String DEFAULT_POLLER = DEFAULT_POLLER_METADATA_BEAN_NAME;
5859

59-
private Trigger trigger;
60+
private @Nullable Trigger trigger;
6061

6162
private long maxMessagesPerPoll = MAX_MESSAGES_UNBOUNDED;
6263

6364
private long receiveTimeout = DEFAULT_RECEIVE_TIMEOUT;
6465

65-
private ErrorHandler errorHandler;
66+
private @Nullable ErrorHandler errorHandler;
6667

67-
private List<Advice> adviceChain;
68+
private @Nullable List<Advice> adviceChain;
6869

69-
private Executor taskExecutor;
70+
private @Nullable Executor taskExecutor;
7071

71-
private TransactionSynchronizationFactory transactionSynchronizationFactory;
72+
private @Nullable TransactionSynchronizationFactory transactionSynchronizationFactory;
7273

7374
public void setTransactionSynchronizationFactory(
7475
TransactionSynchronizationFactory transactionSynchronizationFactory) {
7576
Assert.notNull(transactionSynchronizationFactory, "'transactionSynchronizationFactory' must not be null");
7677
this.transactionSynchronizationFactory = transactionSynchronizationFactory;
7778
}
7879

79-
public TransactionSynchronizationFactory getTransactionSynchronizationFactory() {
80+
public @Nullable TransactionSynchronizationFactory getTransactionSynchronizationFactory() {
8081
return this.transactionSynchronizationFactory;
8182
}
8283

83-
public void setTrigger(Trigger trigger) {
84+
public void setTrigger(@Nullable Trigger trigger) {
8485
this.trigger = trigger;
8586
}
8687

87-
public Trigger getTrigger() {
88+
public @Nullable Trigger getTrigger() {
8889
return this.trigger;
8990
}
9091

91-
public ErrorHandler getErrorHandler() {
92+
public @Nullable ErrorHandler getErrorHandler() {
9293
return this.errorHandler;
9394
}
9495

@@ -124,15 +125,15 @@ public void setAdviceChain(List<Advice> adviceChain) {
124125
this.adviceChain = adviceChain;
125126
}
126127

127-
public List<Advice> getAdviceChain() {
128+
public @Nullable List<Advice> getAdviceChain() {
128129
return this.adviceChain;
129130
}
130131

131132
public void setTaskExecutor(Executor taskExecutor) {
132133
this.taskExecutor = taskExecutor;
133134
}
134135

135-
public Executor getTaskExecutor() {
136+
public @Nullable Executor getTaskExecutor() {
136137
return this.taskExecutor;
137138
}
138139

@@ -141,7 +142,7 @@ public Executor getTaskExecutor() {
141142
* @param beanFactory BeanFactory for lookup, must not be null.
142143
* @return The poller metadata.
143144
*/
144-
public static PollerMetadata getDefaultPollerMetadata(BeanFactory beanFactory) {
145+
public static @Nullable PollerMetadata getDefaultPollerMetadata(BeanFactory beanFactory) {
145146
Assert.notNull(beanFactory, "BeanFactory must not be null");
146147
if (!beanFactory.containsBean(DEFAULT_POLLER_METADATA_BEAN_NAME)) {
147148
return null;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/**
22
* Provides classes related to task scheduling.
33
*/
4+
@org.jspecify.annotations.NullMarked
45
package org.springframework.integration.scheduling;

spring-integration-core/src/main/java/org/springframework/integration/selector/MetadataStoreSelector.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,23 @@ public class MetadataStoreSelector implements MessageSelector {
6565

6666
private final MessageProcessor<String> keyStrategy;
6767

68-
private final MessageProcessor<String> valueStrategy;
68+
private final @Nullable MessageProcessor<String> valueStrategy;
6969

70-
@Nullable
71-
private BiPredicate<String, String> compareValues;
70+
private @Nullable BiPredicate<String, String> compareValues;
7271

7372
public MetadataStoreSelector(MessageProcessor<String> keyStrategy) {
7473
this(keyStrategy, (MessageProcessor<String>) null);
7574
}
7675

77-
public MetadataStoreSelector(MessageProcessor<String> keyStrategy, MessageProcessor<String> valueStrategy) {
76+
public MetadataStoreSelector(MessageProcessor<String> keyStrategy, @Nullable MessageProcessor<String> valueStrategy) {
7877
this(keyStrategy, valueStrategy, new SimpleMetadataStore());
7978
}
8079

8180
public MetadataStoreSelector(MessageProcessor<String> keyStrategy, ConcurrentMetadataStore metadataStore) {
8281
this(keyStrategy, null, metadataStore);
8382
}
8483

85-
public MetadataStoreSelector(MessageProcessor<String> keyStrategy, MessageProcessor<String> valueStrategy,
84+
public MetadataStoreSelector(MessageProcessor<String> keyStrategy, @Nullable MessageProcessor<String> valueStrategy,
8685
ConcurrentMetadataStore metadataStore) {
8786
Assert.notNull(keyStrategy, "'keyStrategy' must not be null");
8887
Assert.notNull(metadataStore, "'metadataStore' must not be null");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/**
22
* Provides classes related to message selection.
33
*/
4+
@org.jspecify.annotations.NullMarked
45
package org.springframework.integration.selector;

0 commit comments

Comments
 (0)