Skip to content

Commit be8165c

Browse files
authored
GH-10083: Add NullAway core package
* GH-10083: Add NullAway core package - Add explicit Consumer cast in AggregatorFactoryBean for lockRegistry method reference to resolve type parameter nullability mismatch - Complete nullability annotation migration for core integration package * GH-10083: Fix @nullable annotation placement in IntegrationMessageHeaderAccessor
1 parent 448cee7 commit be8165c

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

spring-integration-core/src/main/java/org/springframework/integration/IntegrationMessageHeaderAccessor.java

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,11 @@ public void setReadOnlyHeaders(String... readOnlyHeaders) {
114114
}
115115
}
116116

117-
@Nullable
118-
public Long getExpirationDate() {
117+
public @Nullable Long getExpirationDate() {
119118
return getHeader(EXPIRATION_DATE, Long.class);
120119
}
121120

122-
@Nullable
123-
public Object getCorrelationId() {
121+
public @Nullable Object getCorrelationId() {
124122
return getHeader(CORRELATION_ID);
125123
}
126124

@@ -134,8 +132,7 @@ public int getSequenceSize() {
134132
return (sequenceSize != null ? sequenceSize.intValue() : 0);
135133
}
136134

137-
@Nullable
138-
public Integer getPriority() {
135+
public @Nullable Integer getPriority() {
139136
Number priority = getHeader(PRIORITY, Number.class);
140137
return (priority != null ? priority.intValue() : null);
141138
}
@@ -149,8 +146,7 @@ public Integer getPriority() {
149146
* @return the {@link Closeable}.
150147
* @since 4.3
151148
*/
152-
@Nullable
153-
public Closeable getCloseableResource() {
149+
public @Nullable Closeable getCloseableResource() {
154150
return getHeader(CLOSEABLE_RESOURCE, Closeable.class);
155151
}
156152

@@ -159,8 +155,7 @@ public Closeable getCloseableResource() {
159155
* @return the callback.
160156
* @since 5.0.1
161157
*/
162-
@Nullable
163-
public AcknowledgmentCallback getAcknowledgmentCallback() {
158+
public @Nullable AcknowledgmentCallback getAcknowledgmentCallback() {
164159
return getHeader(ACKNOWLEDGMENT_CALLBACK, AcknowledgmentCallback.class);
165160
}
166161

@@ -170,8 +165,7 @@ public AcknowledgmentCallback getAcknowledgmentCallback() {
170165
* @return the delivery attempt.
171166
* @since 5.0.1
172167
*/
173-
@Nullable
174-
public AtomicInteger getDeliveryAttempt() {
168+
public @Nullable AtomicInteger getDeliveryAttempt() {
175169
return getHeader(DELIVERY_ATTEMPT, AtomicInteger.class);
176170
}
177171

@@ -182,8 +176,7 @@ public AtomicInteger getDeliveryAttempt() {
182176
* @since 5.1.6
183177
*/
184178
@SuppressWarnings("unchecked")
185-
@Nullable
186-
public <T> T getSourceData() {
179+
public <T> @Nullable T getSourceData() {
187180
return (T) getHeader(SOURCE_DATA);
188181
}
189182

@@ -192,14 +185,12 @@ public <T> T getSourceData() {
192185
* @return the {@link ContextView} header if present.
193186
* @since 6.0.5
194187
*/
195-
@Nullable
196-
public ContextView getReactorContext() {
188+
public @Nullable ContextView getReactorContext() {
197189
return getHeader(REACTOR_CONTEXT, ContextView.class);
198190
}
199191

200192
@SuppressWarnings("unchecked")
201-
@Nullable
202-
public <T> T getHeader(String key, Class<T> type) {
193+
public <T> @Nullable T getHeader(String key, Class<T> type) {
203194
Object value = getHeader(key);
204195
if (value == null) {
205196
return null;
@@ -212,7 +203,7 @@ public <T> T getHeader(String key, Class<T> type) {
212203
}
213204

214205
@Override
215-
protected void verifyType(String headerName, Object headerValue) {
206+
protected void verifyType(@Nullable String headerName, @Nullable Object headerValue) {
216207
if (headerName != null && headerValue != null) {
217208
super.verifyType(headerName, headerValue);
218209
if (IntegrationMessageHeaderAccessor.EXPIRATION_DATE.equals(headerName)) {

spring-integration-core/src/main/java/org/springframework/integration/config/AggregatorFactoryBean.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.List;
2121
import java.util.Map;
2222
import java.util.function.BiFunction;
23+
import java.util.function.Consumer;
2324
import java.util.function.Function;
2425

2526
import org.aopalliance.aop.Advice;
@@ -238,7 +239,7 @@ protected AggregatingMessageHandler createHandler() {
238239
.acceptIfNotNull(this.expireGroupsUponCompletion, aggregator::setExpireGroupsUponCompletion)
239240
.acceptIfNotNull(this.sendTimeout, aggregator::setSendTimeout)
240241
.acceptIfNotNull(this.outputChannelName, aggregator::setOutputChannelName)
241-
.acceptIfNotNull(this.lockRegistry, aggregator::setLockRegistry)
242+
.acceptIfNotNull(this.lockRegistry, (Consumer<LockRegistry<?>>) aggregator::setLockRegistry)
242243
.acceptIfNotNull(this.messageStore, aggregator::setMessageStore)
243244
.acceptIfNotNull(obtainCorrelationStrategy(), aggregator::setCorrelationStrategy)
244245
.acceptIfNotNull(obtainReleaseStrategy(), aggregator::setReleaseStrategy)

spring-integration-core/src/main/java/org/springframework/integration/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
*
44
* Provides fundamental classes.
55
*/
6-
@org.springframework.lang.NonNullApi
6+
@org.jspecify.annotations.NullMarked
77
package org.springframework.integration;

0 commit comments

Comments
 (0)