Skip to content

Commit 1b9ee5d

Browse files
committed
Add nullability to org.springframework.messaging.core package
1 parent de180e4 commit 1b9ee5d

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2019 the original author or authors.
2+
* Copyright 2017-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.
@@ -18,6 +18,7 @@
1818

1919
import org.apache.commons.logging.Log;
2020
import org.apache.commons.logging.LogFactory;
21+
import org.jspecify.annotations.Nullable;
2122

2223
import org.springframework.beans.factory.BeanFactory;
2324
import org.springframework.beans.factory.BeanFactoryAware;
@@ -27,7 +28,6 @@
2728
import org.springframework.integration.support.ErrorMessageStrategy;
2829
import org.springframework.integration.support.ErrorMessageUtils;
2930
import org.springframework.integration.support.channel.ChannelResolverUtils;
30-
import org.springframework.lang.Nullable;
3131
import org.springframework.messaging.Message;
3232
import org.springframework.messaging.MessageChannel;
3333
import org.springframework.messaging.MessagingException;
@@ -54,10 +54,13 @@ public class ErrorMessagePublisher implements BeanFactoryAware {
5454

5555
protected final MessagingTemplate messagingTemplate = new MessagingTemplate(); // NOSONAR final
5656

57+
@SuppressWarnings("NullAway.Init")
5758
private DestinationResolver<MessageChannel> channelResolver;
5859

60+
@Nullable
5961
private MessageChannel channel;
6062

63+
@Nullable
6164
private String channelName;
6265

6366
private ErrorMessageStrategy errorMessageStrategy = new DefaultErrorMessageStrategy();
@@ -79,6 +82,7 @@ public ErrorMessageStrategy getErrorMessageStrategy() {
7982
return this.errorMessageStrategy;
8083
}
8184

85+
@Nullable
8286
public MessageChannel getChannel() {
8387
populateChannel();
8488
return this.channel;
@@ -146,7 +150,7 @@ public void publish(Message<?> inputMessage, MessagingException exception) {
146150
* @param failedMessage the message.
147151
* @param throwable the throwable.
148152
*/
149-
public void publish(@Nullable Message<?> inputMessage, Message<?> failedMessage, Throwable throwable) {
153+
public void publish(@Nullable Message<?> inputMessage, @Nullable Message<?> failedMessage, Throwable throwable) {
150154
publish(throwable, ErrorMessageUtils.getAttributeAccessor(inputMessage, failedMessage));
151155
}
152156

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-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,7 +16,8 @@
1616

1717
package org.springframework.integration.core;
1818

19-
import org.springframework.lang.Nullable;
19+
import org.jspecify.annotations.Nullable;
20+
2021
import org.springframework.messaging.MessageChannel;
2122

2223
/**

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
import java.util.concurrent.locks.Lock;
2020
import java.util.concurrent.locks.ReentrantLock;
2121

22+
import org.jspecify.annotations.Nullable;
23+
2224
import org.springframework.beans.BeansException;
2325
import org.springframework.beans.factory.BeanFactory;
2426
import org.springframework.integration.context.IntegrationContextUtils;
2527
import org.springframework.integration.context.IntegrationProperties;
2628
import org.springframework.integration.support.channel.ChannelResolverUtils;
27-
import org.springframework.lang.Nullable;
2829
import org.springframework.messaging.Message;
2930
import org.springframework.messaging.MessageChannel;
3031
import org.springframework.messaging.core.GenericMessagingTemplate;
@@ -43,6 +44,7 @@ public class MessagingTemplate extends GenericMessagingTemplate {
4344

4445
private final Lock lock = new ReentrantLock();
4546

47+
@SuppressWarnings("NullAway.Init")
4648
private BeanFactory beanFactory;
4749

4850
private volatile boolean throwExceptionOnLateReplySet;
@@ -83,7 +85,7 @@ public void setThrowExceptionOnLateReply(boolean throwExceptionOnLateReply) {
8385
* backward compatibility.
8486
* @param channel the channel to set.
8587
*/
86-
public void setDefaultChannel(MessageChannel channel) {
88+
public void setDefaultChannel(@Nullable MessageChannel channel) {
8789
super.setDefaultDestination(channel);
8890
}
8991

@@ -108,6 +110,7 @@ public Message<?> sendAndReceive(MessageChannel destination, Message<?> requestM
108110
return super.sendAndReceive(destination, requestMessage);
109111
}
110112

113+
@Nullable
111114
public Object receiveAndConvert(MessageChannel destination, long timeout) {
112115
Message<?> message = doReceive(destination, timeout);
113116
if (message != null) {
@@ -117,7 +120,7 @@ public Object receiveAndConvert(MessageChannel destination, long timeout) {
117120
return null;
118121
}
119122
}
120-
123+
@Nullable
121124
public Message<?> receive(MessageChannel destination, long timeout) {
122125
return doReceive(destination, timeout);
123126
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/**
22
* Provides core classes.
33
*/
4+
@org.jspecify.annotations.NullMarked
45
package org.springframework.integration.core;

0 commit comments

Comments
 (0)