Skip to content

Commit de180e4

Browse files
committed
Update SI Core to add Nullability to module
This is a first pass at the module to make sure it is being converted properly. Related to #10083
1 parent 260073d commit de180e4

File tree

5 files changed

+40
-4
lines changed

5 files changed

+40
-4
lines changed

spring-integration-core/src/main/java/org/springframework/integration/context/ExpressionCapable.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,9 @@
1616

1717
package org.springframework.integration.context;
1818

19+
20+
import org.jspecify.annotations.Nullable;
21+
1922
import org.springframework.expression.Expression;
2023

2124
/**
@@ -32,6 +35,7 @@ public interface ExpressionCapable {
3235
* Return the primary SpEL expression if this component is expression-based.
3336
* @return the expression as a String.
3437
*/
38+
@Nullable
3539
Expression getExpression();
3640

3741
}

spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationContextUtils.java

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

1717
package org.springframework.integration.context;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.beans.factory.BeanFactory;
2022
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
2123
import org.springframework.beans.factory.config.BeanDefinition;
@@ -120,6 +122,7 @@ public abstract class IntegrationContextUtils {
120122
* @param beanFactory BeanFactory for lookup, must not be null.
121123
* @return The {@link MetadataStore} bean whose name is "metadataStore".
122124
*/
125+
@Nullable
123126
public static MetadataStore getMetadataStore(BeanFactory beanFactory) {
124127
return getBeanOfType(beanFactory, METADATA_STORE_BEAN_NAME, MetadataStore.class);
125128
}
@@ -128,6 +131,7 @@ public static MetadataStore getMetadataStore(BeanFactory beanFactory) {
128131
* @param beanFactory BeanFactory for lookup, must not be null.
129132
* @return The {@link MessageChannel} bean whose name is "errorChannel".
130133
*/
134+
@Nullable
131135
public static MessageChannel getErrorChannel(BeanFactory beanFactory) {
132136
return getBeanOfType(beanFactory, ERROR_CHANNEL_BEAN_NAME, MessageChannel.class);
133137
}
@@ -136,6 +140,7 @@ public static MessageChannel getErrorChannel(BeanFactory beanFactory) {
136140
* @param beanFactory BeanFactory for lookup, must not be null.
137141
* @return The {@link TaskScheduler} bean whose name is "taskScheduler" if available.
138142
*/
143+
@Nullable
139144
public static TaskScheduler getTaskScheduler(BeanFactory beanFactory) {
140145
return getBeanOfType(beanFactory, TASK_SCHEDULER_BEAN_NAME, TaskScheduler.class);
141146
}
@@ -156,6 +161,7 @@ public static TaskScheduler getRequiredTaskScheduler(BeanFactory beanFactory) {
156161
* @return the instance of {@link StandardEvaluationContext} bean whose name is
157162
* {@value #INTEGRATION_EVALUATION_CONTEXT_BEAN_NAME}.
158163
*/
164+
@Nullable
159165
public static StandardEvaluationContext getEvaluationContext(BeanFactory beanFactory) {
160166
return getBeanOfType(beanFactory, INTEGRATION_EVALUATION_CONTEXT_BEAN_NAME, StandardEvaluationContext.class);
161167
}
@@ -166,11 +172,13 @@ public static StandardEvaluationContext getEvaluationContext(BeanFactory beanFac
166172
* {@value #INTEGRATION_SIMPLE_EVALUATION_CONTEXT_BEAN_NAME}.
167173
* @since 4.3.15
168174
*/
175+
@Nullable
169176
public static SimpleEvaluationContext getSimpleEvaluationContext(BeanFactory beanFactory) {
170177
return getBeanOfType(beanFactory, INTEGRATION_SIMPLE_EVALUATION_CONTEXT_BEAN_NAME,
171178
SimpleEvaluationContext.class);
172179
}
173180

181+
@Nullable
174182
private static <T> T getBeanOfType(BeanFactory beanFactory, String beanName, Class<T> type) {
175183
Assert.notNull(beanFactory, "BeanFactory must not be null");
176184
if (!beanFactory.containsBean(beanName)) {

spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationObjectSupport.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import java.util.UUID;
2020

21+
import org.jspecify.annotations.Nullable;
22+
2123
import org.springframework.aop.framework.AopProxyUtils;
2224
import org.springframework.beans.BeansException;
2325
import org.springframework.beans.factory.BeanFactory;
@@ -37,7 +39,6 @@
3739
import org.springframework.integration.support.channel.ChannelResolverUtils;
3840
import org.springframework.integration.support.context.NamedComponent;
3941
import org.springframework.integration.support.utils.IntegrationUtils;
40-
import org.springframework.lang.Nullable;
4142
import org.springframework.messaging.MessageChannel;
4243
import org.springframework.messaging.core.DestinationResolver;
4344
import org.springframework.scheduling.TaskScheduler;
@@ -71,38 +72,50 @@ public abstract class IntegrationObjectSupport implements ComponentSourceAware,
7172

7273
protected final LogAccessor logger = new LogAccessor(getClass()); // NOSONAR protected
7374

75+
@SuppressWarnings("NullAway.Init")
7476
private DestinationResolver<MessageChannel> channelResolver;
7577

78+
@SuppressWarnings("NullAway.Init")
7679
private String beanName;
7780

81+
@Nullable
7882
private String componentName;
7983

84+
@SuppressWarnings("NullAway.Init")
8085
private BeanFactory beanFactory;
8186

87+
@Nullable
8288
private TaskScheduler taskScheduler;
8389

8490
private IntegrationProperties integrationProperties = new IntegrationProperties();
8591

92+
@Nullable
8693
private ConversionService conversionService;
8794

95+
@SuppressWarnings("NullAway.Init")
8896
private ApplicationContext applicationContext;
8997

98+
@SuppressWarnings("NullAway.Init")
9099
private MessageBuilderFactory messageBuilderFactory;
91100

101+
@Nullable
92102
private Expression expression;
93103

104+
@Nullable
94105
private Object beanSource;
95106

107+
@Nullable
96108
private String beanDescription;
97109

98110
private boolean initialized;
99111

100112
@Override
101-
public final void setBeanName(@Nullable String beanName) {
113+
public final void setBeanName(String beanName) {
102114
this.beanName = beanName;
103115
}
104116

105117
@Override
118+
@Nullable
106119
public String getBeanName() {
107120
return this.beanName;
108121
}
@@ -112,6 +125,7 @@ public String getBeanName() {
112125
* If {@link #componentName} was not set this method will default to the 'beanName' of this component;
113126
*/
114127
@Override
128+
@Nullable
115129
public String getComponentName() {
116130
return StringUtils.hasText(this.componentName) ? this.componentName : this.beanName;
117131
}
@@ -127,6 +141,7 @@ public void setComponentName(String componentName) {
127141
/**
128142
* Subclasses may implement this method to provide component type information.
129143
*/
144+
@Nullable
130145
@Override
131146
public String getComponentType() {
132147
return null;
@@ -194,6 +209,7 @@ public void setChannelResolver(DestinationResolver<MessageChannel> channelResolv
194209
}
195210

196211
@Override
212+
@Nullable
197213
public Expression getExpression() {
198214
return this.expression;
199215
}
@@ -207,6 +223,7 @@ public final void setPrimaryExpression(Expression expression) {
207223
this.expression = expression;
208224
}
209225

226+
@SuppressWarnings("NullAway.Init")
210227
@Override
211228
public final void afterPropertiesSet() {
212229
this.integrationProperties = IntegrationContextUtils.getIntegrationProperties(this.beanFactory);
@@ -263,6 +280,7 @@ public void setTaskScheduler(TaskScheduler taskScheduler) {
263280
this.taskScheduler = taskScheduler;
264281
}
265282

283+
@Nullable
266284
protected TaskScheduler getTaskScheduler() {
267285
if (this.taskScheduler == null && this.beanFactory != null) {
268286
this.taskScheduler = IntegrationContextUtils.getTaskScheduler(this.beanFactory);
@@ -277,6 +295,7 @@ protected DestinationResolver<MessageChannel> getChannelResolver() {
277295
return this.channelResolver;
278296
}
279297

298+
@Nullable
280299
public ConversionService getConversionService() {
281300
if (this.conversionService == null && this.beanFactory != null) {
282301
this.conversionService = IntegrationUtils.getConversionService(this.beanFactory);
@@ -298,6 +317,7 @@ public void setConversionService(ConversionService conversionService) {
298317
* {@link ApplicationContext} is available.
299318
* @return The id, or null if there is no application context.
300319
*/
320+
@Nullable
301321
public String getApplicationContextId() {
302322
return this.applicationContext == null ? null : this.applicationContext.getId();
303323
}

spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationProperties.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2024 the original author or authors.
2+
* Copyright 2014-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,8 @@
1919
import java.util.Arrays;
2020
import java.util.Properties;
2121

22+
import org.jspecify.annotations.Nullable;
23+
2224
import org.springframework.integration.JavaUtils;
2325
import org.springframework.util.Assert;
2426
import org.springframework.util.StringUtils;
@@ -139,6 +141,7 @@ public final class IntegrationProperties {
139141

140142
private long endpointsDefaultTimeout = IntegrationContextUtils.DEFAULT_TIMEOUT;
141143

144+
@Nullable
142145
private volatile Properties properties;
143146

144147
static {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/**
22
* Provides classes relating to application context configuration.
33
*/
4+
@org.jspecify.annotations.NullMarked
45
package org.springframework.integration.context;

0 commit comments

Comments
 (0)