Skip to content

Commit 427ed3e

Browse files
knalliartembilan
authored andcommitted
GH-871: Add missing @Nullable
Resolves #871 * Add missing `@Nullable` Relates #871 * Fixup order of imports
1 parent 963b3b7 commit 427ed3e

File tree

5 files changed

+45
-2
lines changed

5 files changed

+45
-2
lines changed

spring-amqp/src/main/java/org/springframework/amqp/core/AmqpAdmin.java

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

1919
import java.util.Properties;
2020

21+
import org.springframework.lang.Nullable;
22+
2123

2224
/**
2325
* Specifies a basic set of portable AMQP administrative operations for AMQP > 0.9.
@@ -50,13 +52,15 @@ public interface AmqpAdmin {
5052
*
5153
* @return The queue.
5254
*/
55+
@Nullable
5356
Queue declareQueue();
5457

5558
/**
5659
* Declare the given queue.
5760
* @param queue the queue to declare.
5861
* @return the name of the queue.
5962
*/
63+
@Nullable
6064
String declareQueue(Queue queue);
6165

6266
/**
@@ -111,6 +115,7 @@ public interface AmqpAdmin {
111115
* @param queueName the name of the queue.
112116
* @return the properties or null if the queue doesn't exist.
113117
*/
118+
@Nullable
114119
Properties getQueueProperties(String queueName);
115120

116121
/**

spring-amqp/src/main/java/org/springframework/amqp/core/AmqpTemplate.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.springframework.amqp.AmqpException;
2020
import org.springframework.amqp.support.converter.MessageConverter;
2121
import org.springframework.core.ParameterizedTypeReference;
22+
import org.springframework.lang.Nullable;
2223

2324
/**
2425
* Specifies a basic set of AMQP operations.
@@ -141,6 +142,7 @@ void convertAndSend(String exchange, String routingKey, Object message, MessageP
141142
* @return a message or null if there is none waiting
142143
* @throws AmqpException if there is a problem
143144
*/
145+
@Nullable
144146
Message receive() throws AmqpException;
145147

146148
/**
@@ -151,6 +153,7 @@ void convertAndSend(String exchange, String routingKey, Object message, MessageP
151153
* @return a message or null if there is none waiting
152154
* @throws AmqpException if there is a problem
153155
*/
156+
@Nullable
154157
Message receive(String queueName) throws AmqpException;
155158

156159
/**
@@ -164,6 +167,7 @@ void convertAndSend(String exchange, String routingKey, Object message, MessageP
164167
* @throws AmqpException if there is a problem
165168
* @since 1.6
166169
*/
170+
@Nullable
167171
Message receive(long timeoutMillis) throws AmqpException;
168172

169173
/**
@@ -178,6 +182,7 @@ void convertAndSend(String exchange, String routingKey, Object message, MessageP
178182
* @throws AmqpException if there is a problem
179183
* @since 1.6
180184
*/
185+
@Nullable
181186
Message receive(String queueName, long timeoutMillis) throws AmqpException;
182187

183188
// receive methods with conversion
@@ -189,6 +194,7 @@ void convertAndSend(String exchange, String routingKey, Object message, MessageP
189194
* @return a message or null if there is none waiting
190195
* @throws AmqpException if there is a problem
191196
*/
197+
@Nullable
192198
Object receiveAndConvert() throws AmqpException;
193199

194200
/**
@@ -199,6 +205,7 @@ void convertAndSend(String exchange, String routingKey, Object message, MessageP
199205
* @return a message or null if there is none waiting
200206
* @throws AmqpException if there is a problem
201207
*/
208+
@Nullable
202209
Object receiveAndConvert(String queueName) throws AmqpException;
203210

204211
/**
@@ -213,6 +220,7 @@ void convertAndSend(String exchange, String routingKey, Object message, MessageP
213220
* @throws AmqpException if there is a problem
214221
* @since 1.6
215222
*/
223+
@Nullable
216224
Object receiveAndConvert(long timeoutMillis) throws AmqpException;
217225

218226
/**
@@ -228,6 +236,7 @@ void convertAndSend(String exchange, String routingKey, Object message, MessageP
228236
* @throws AmqpException if there is a problem
229237
* @since 1.6
230238
*/
239+
@Nullable
231240
Object receiveAndConvert(String queueName, long timeoutMillis) throws AmqpException;
232241

233242
/**
@@ -241,6 +250,7 @@ void convertAndSend(String exchange, String routingKey, Object message, MessageP
241250
* @throws AmqpException if there is a problem.
242251
* @since 2.0
243252
*/
253+
@Nullable
244254
<T> T receiveAndConvert(ParameterizedTypeReference<T> type) throws AmqpException;
245255

246256
/**
@@ -255,6 +265,7 @@ void convertAndSend(String exchange, String routingKey, Object message, MessageP
255265
* @throws AmqpException if there is a problem
256266
* @since 2.0
257267
*/
268+
@Nullable
258269
<T> T receiveAndConvert(String queueName, ParameterizedTypeReference<T> type) throws AmqpException;
259270

260271
/**
@@ -272,6 +283,7 @@ void convertAndSend(String exchange, String routingKey, Object message, MessageP
272283
* @throws AmqpException if there is a problem
273284
* @since 2.0
274285
*/
286+
@Nullable
275287
<T> T receiveAndConvert(long timeoutMillis, ParameterizedTypeReference<T> type) throws AmqpException;
276288

277289
/**
@@ -290,6 +302,7 @@ void convertAndSend(String exchange, String routingKey, Object message, MessageP
290302
* @throws AmqpException if there is a problem
291303
* @since 2.0
292304
*/
305+
@Nullable
293306
<T> T receiveAndConvert(String queueName, long timeoutMillis, ParameterizedTypeReference<T> type)
294307
throws AmqpException;
295308

@@ -410,6 +423,7 @@ <R, S> boolean receiveAndReply(String queueName, ReceiveAndReplyCallback<R, S> c
410423
* @return the response if there is one
411424
* @throws AmqpException if there is a problem
412425
*/
426+
@Nullable
413427
Message sendAndReceive(Message message) throws AmqpException;
414428

415429
/**
@@ -422,6 +436,7 @@ <R, S> boolean receiveAndReply(String queueName, ReceiveAndReplyCallback<R, S> c
422436
* @return the response if there is one
423437
* @throws AmqpException if there is a problem
424438
*/
439+
@Nullable
425440
Message sendAndReceive(String routingKey, Message message) throws AmqpException;
426441

427442
/**
@@ -436,6 +451,7 @@ <R, S> boolean receiveAndReply(String queueName, ReceiveAndReplyCallback<R, S> c
436451
* @return the response if there is one
437452
* @throws AmqpException if there is a problem
438453
*/
454+
@Nullable
439455
Message sendAndReceive(String exchange, String routingKey, Message message) throws AmqpException;
440456

441457
// send and receive methods with conversion
@@ -450,6 +466,7 @@ <R, S> boolean receiveAndReply(String queueName, ReceiveAndReplyCallback<R, S> c
450466
* @return the response if there is one
451467
* @throws AmqpException if there is a problem
452468
*/
469+
@Nullable
453470
Object convertSendAndReceive(Object message) throws AmqpException;
454471

455472
/**
@@ -463,6 +480,7 @@ <R, S> boolean receiveAndReply(String queueName, ReceiveAndReplyCallback<R, S> c
463480
* @return the response if there is one
464481
* @throws AmqpException if there is a problem
465482
*/
483+
@Nullable
466484
Object convertSendAndReceive(String routingKey, Object message) throws AmqpException;
467485

468486
/**
@@ -477,6 +495,7 @@ <R, S> boolean receiveAndReply(String queueName, ReceiveAndReplyCallback<R, S> c
477495
* @return the response if there is one
478496
* @throws AmqpException if there is a problem
479497
*/
498+
@Nullable
480499
Object convertSendAndReceive(String exchange, String routingKey, Object message) throws AmqpException;
481500

482501
/**
@@ -490,6 +509,7 @@ <R, S> boolean receiveAndReply(String queueName, ReceiveAndReplyCallback<R, S> c
490509
* @return the response if there is one
491510
* @throws AmqpException if there is a problem
492511
*/
512+
@Nullable
493513
Object convertSendAndReceive(Object message, MessagePostProcessor messagePostProcessor) throws AmqpException;
494514

495515
/**
@@ -504,6 +524,7 @@ <R, S> boolean receiveAndReply(String queueName, ReceiveAndReplyCallback<R, S> c
504524
* @return the response if there is one
505525
* @throws AmqpException if there is a problem
506526
*/
527+
@Nullable
507528
Object convertSendAndReceive(String routingKey, Object message, MessagePostProcessor messagePostProcessor)
508529
throws AmqpException;
509530

@@ -520,6 +541,7 @@ Object convertSendAndReceive(String routingKey, Object message, MessagePostProce
520541
* @return the response if there is one
521542
* @throws AmqpException if there is a problem
522543
*/
544+
@Nullable
523545
Object convertSendAndReceive(String exchange, String routingKey, Object message,
524546
MessagePostProcessor messagePostProcessor) throws AmqpException;
525547

@@ -537,6 +559,7 @@ Object convertSendAndReceive(String exchange, String routingKey, Object message,
537559
* @throws AmqpException if there is a problem.
538560
* @since 2.0
539561
*/
562+
@Nullable
540563
<T> T convertSendAndReceiveAsType(Object message, ParameterizedTypeReference<T> responseType)
541564
throws AmqpException;
542565

@@ -554,6 +577,7 @@ <T> T convertSendAndReceiveAsType(Object message, ParameterizedTypeReference<T>
554577
* @throws AmqpException if there is a problem
555578
* @since 2.0
556579
*/
580+
@Nullable
557581
<T> T convertSendAndReceiveAsType(String routingKey, Object message,
558582
ParameterizedTypeReference<T> responseType) throws AmqpException;
559583

@@ -572,6 +596,7 @@ <T> T convertSendAndReceiveAsType(String routingKey, Object message,
572596
* @throws AmqpException if there is a problem
573597
* @since 2.0
574598
*/
599+
@Nullable
575600
<T> T convertSendAndReceiveAsType(String exchange, String routingKey, Object message,
576601
ParameterizedTypeReference<T> responseType) throws AmqpException;
577602

@@ -589,6 +614,7 @@ <T> T convertSendAndReceiveAsType(String exchange, String routingKey, Object mes
589614
* @throws AmqpException if there is a problem
590615
* @since 2.0
591616
*/
617+
@Nullable
592618
<T> T convertSendAndReceiveAsType(Object message, MessagePostProcessor messagePostProcessor,
593619
ParameterizedTypeReference<T> responseType) throws AmqpException;
594620

@@ -607,6 +633,7 @@ <T> T convertSendAndReceiveAsType(Object message, MessagePostProcessor messagePo
607633
* @throws AmqpException if there is a problem
608634
* @since 2.0
609635
*/
636+
@Nullable
610637
<T> T convertSendAndReceiveAsType(String routingKey, Object message,
611638
MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<T> responseType)
612639
throws AmqpException;
@@ -627,6 +654,7 @@ <T> T convertSendAndReceiveAsType(String routingKey, Object message,
627654
* @throws AmqpException if there is a problem
628655
* @since 2.0
629656
*/
657+
@Nullable
630658
<T> T convertSendAndReceiveAsType(String exchange, String routingKey, Object message,
631659
MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<T> responseType)
632660
throws AmqpException;

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/ChannelCallback.java

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

1717
package org.springframework.amqp.rabbit.core;
1818

19+
import org.springframework.lang.Nullable;
20+
1921
import com.rabbitmq.client.Channel;
2022

2123
/**
@@ -36,6 +38,7 @@ public interface ChannelCallback<T> {
3638
* @return The result.
3739
* @throws Exception Not sure what else Rabbit Throws
3840
*/
41+
@Nullable
3942
T doInRabbit(Channel channel) throws Exception; // NOSONAR user code might throw anything; cannot change
4043

4144
}

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitAdmin.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ public boolean deleteExchange(final String exchangeName) {
263263
@Override
264264
@ManagedOperation(description =
265265
"Declare a queue on the broker (this operation is not available remotely)")
266+
@Nullable
266267
public String declareQueue(final Queue queue) {
267268
try {
268269
return this.rabbitTemplate.execute(channel -> {
@@ -388,6 +389,7 @@ public void removeBinding(final Binding binding) {
388389
*/
389390
@Override
390391
@ManagedOperation(description = "Get queue name, message count and consumer count")
392+
@Nullable
391393
public Properties getQueueProperties(final String queueName) {
392394
Assert.hasText(queueName, "'queueName' cannot be null or empty");
393395
return this.rabbitTemplate.execute(channel -> {
@@ -434,7 +436,7 @@ public Properties getQueueProperties(final String queueName) {
434436
* @param retryTemplate the retry template.
435437
* @since 1.7.8
436438
*/
437-
public void setRetryTemplate(RetryTemplate retryTemplate) {
439+
public void setRetryTemplate(@Nullable RetryTemplate retryTemplate) {
438440
this.retryTemplate = retryTemplate;
439441
if (retryTemplate == null) {
440442
this.retryDisabled = true;

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,11 +1013,13 @@ public void convertAndSend(String exchange, String routingKey, final Object mess
10131013
}
10141014

10151015
@Override
1016+
@Nullable
10161017
public Message receive() throws AmqpException {
10171018
return this.receive(getRequiredQueue());
10181019
}
10191020

10201021
@Override
1022+
@Nullable
10211023
public Message receive(String queueName) {
10221024
if (this.receiveTimeout == 0) {
10231025
return doReceiveNoWait(queueName);
@@ -1033,6 +1035,7 @@ public Message receive(String queueName) {
10331035
* @return The message, or null if none immediately available.
10341036
* @since 1.5
10351037
*/
1038+
@Nullable
10361039
protected Message doReceiveNoWait(final String queueName) {
10371040
Message message = execute(channel -> {
10381041
GetResponse response = channel.basicGet(queueName, !isChannelTransacted());
@@ -1934,11 +1937,13 @@ public Boolean isMandatoryFor(final Message message) {
19341937
}
19351938

19361939
@Override
1940+
@Nullable
19371941
public <T> T execute(ChannelCallback<T> action) {
19381942
return execute(action, getConnectionFactory());
19391943
}
19401944

19411945
@SuppressWarnings(UNCHECKED)
1946+
@Nullable
19421947
private <T> T execute(final ChannelCallback<T> action, final ConnectionFactory connectionFactory) {
19431948
if (this.retryTemplate != null) {
19441949
try {
@@ -1958,7 +1963,7 @@ private <T> T execute(final ChannelCallback<T> action, final ConnectionFactory c
19581963
}
19591964
}
19601965

1961-
1966+
@Nullable
19621967
private <T> T doExecute(ChannelCallback<T> action, ConnectionFactory connectionFactory) { // NOSONAR complexity
19631968
Assert.notNull(action, "Callback object must not be null");
19641969
Channel channel = null;

0 commit comments

Comments
 (0)