Skip to content

Commit 05420a6

Browse files
committed
More nullability for AmqpTemplate hierarchy
1 parent daa0afd commit 05420a6

File tree

3 files changed

+62
-58
lines changed

3 files changed

+62
-58
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public interface AmqpTemplate {
8787
* @param message a message to send
8888
* @throws AmqpException if there is a problem
8989
*/
90-
void convertAndSend(String routingKey, Object message) throws AmqpException;
90+
void convertAndSend(@Nullable String routingKey, Object message) throws AmqpException;
9191

9292
/**
9393
* Convert a Java object to an Amqp {@link Message} and send it to a specific exchange
@@ -98,7 +98,7 @@ public interface AmqpTemplate {
9898
* @param message a message to send
9999
* @throws AmqpException if there is a problem
100100
*/
101-
void convertAndSend(String exchange, String routingKey, Object message) throws AmqpException;
101+
void convertAndSend(@Nullable String exchange, @Nullable String routingKey, Object message) throws AmqpException;
102102

103103
/**
104104
* Convert a Java object to an Amqp {@link Message} and send it to a default exchange
@@ -119,7 +119,7 @@ public interface AmqpTemplate {
119119
* @param messagePostProcessor a processor to apply to the message before it is sent
120120
* @throws AmqpException if there is a problem
121121
*/
122-
void convertAndSend(String routingKey, Object message, MessagePostProcessor messagePostProcessor)
122+
void convertAndSend(@Nullable String routingKey, Object message, MessagePostProcessor messagePostProcessor)
123123
throws AmqpException;
124124

125125
/**
@@ -132,8 +132,8 @@ void convertAndSend(String routingKey, Object message, MessagePostProcessor mess
132132
* @param messagePostProcessor a processor to apply to the message before it is sent
133133
* @throws AmqpException if there is a problem
134134
*/
135-
void convertAndSend(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor)
136-
throws AmqpException;
135+
void convertAndSend(@Nullable String exchange, @Nullable String routingKey, Object message,
136+
MessagePostProcessor messagePostProcessor) throws AmqpException;
137137

138138
// receive methods for messages
139139

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

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public interface RabbitOperations extends AmqpTemplate, Lifecycle {
115115
* @throws AmqpException if there is a problem
116116
* @since 2.3
117117
*/
118-
default void send(String routingKey, Message message, CorrelationData correlationData)
118+
default void send(@Nullable String routingKey, Message message, @Nullable CorrelationData correlationData)
119119
throws AmqpException {
120120

121121
throw new UnsupportedOperationException("This implementation does not support this method");
@@ -130,13 +130,13 @@ default void send(String routingKey, Message message, CorrelationData correlatio
130130
* @param correlationData data to correlate publisher confirms.
131131
* @throws AmqpException if there is a problem
132132
*/
133-
void send(String exchange, String routingKey, Message message, @Nullable CorrelationData correlationData)
133+
void send(@Nullable String exchange, @Nullable String routingKey, Message message,
134+
@Nullable CorrelationData correlationData)
134135
throws AmqpException;
135136

136137
/**
137138
* Convert a Java object to an Amqp {@link Message} and send it to a default exchange
138139
* with a default routing key.
139-
*
140140
* @param message a message to send
141141
* @param correlationData data to correlate publisher confirms.
142142
* @throws AmqpException if there is a problem
@@ -152,19 +152,20 @@ void send(String exchange, String routingKey, Message message, @Nullable Correla
152152
* @param correlationData data to correlate publisher confirms.
153153
* @throws AmqpException if there is a problem
154154
*/
155-
void convertAndSend(String routingKey, Object message, CorrelationData correlationData) throws AmqpException;
155+
void convertAndSend(@Nullable String routingKey, Object message, @Nullable CorrelationData correlationData)
156+
throws AmqpException;
156157

157158
/**
158159
* Convert a Java object to an Amqp {@link Message} and send it to a specific exchange
159160
* with a specific routing key.
160-
*
161161
* @param exchange the name of the exchange
162162
* @param routingKey the routing key
163163
* @param message a message to send
164164
* @param correlationData data to correlate publisher confirms.
165165
* @throws AmqpException if there is a problem
166166
*/
167-
void convertAndSend(String exchange, String routingKey, Object message, CorrelationData correlationData)
167+
void convertAndSend(@Nullable String exchange, @Nullable String routingKey, Object message,
168+
@Nullable CorrelationData correlationData)
168169
throws AmqpException;
169170

170171
/**
@@ -176,7 +177,8 @@ void convertAndSend(String exchange, String routingKey, Object message, Correlat
176177
* @param correlationData data to correlate publisher confirms.
177178
* @throws AmqpException if there is a problem
178179
*/
179-
void convertAndSend(Object message, MessagePostProcessor messagePostProcessor, CorrelationData correlationData)
180+
void convertAndSend(Object message, MessagePostProcessor messagePostProcessor,
181+
@Nullable CorrelationData correlationData)
180182
throws AmqpException;
181183

182184
/**
@@ -189,36 +191,36 @@ void convertAndSend(Object message, MessagePostProcessor messagePostProcessor, C
189191
* @param correlationData data to correlate publisher confirms.
190192
* @throws AmqpException if there is a problem
191193
*/
192-
void convertAndSend(String routingKey, Object message, MessagePostProcessor messagePostProcessor,
193-
CorrelationData correlationData) throws AmqpException;
194+
void convertAndSend(@Nullable String routingKey, Object message, MessagePostProcessor messagePostProcessor,
195+
@Nullable CorrelationData correlationData)
196+
throws AmqpException;
194197

195198
/**
196199
* Convert a Java object to an Amqp {@link Message} and send it to a specific exchange
197200
* with a specific routing key.
198-
*
199201
* @param exchange the name of the exchange
200202
* @param routingKey the routing key
201203
* @param message a message to send
202204
* @param messagePostProcessor a processor to apply to the message before it is sent
203205
* @param correlationData data to correlate publisher confirms.
204206
* @throws AmqpException if there is a problem
205207
*/
206-
void convertAndSend(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor,
207-
@Nullable CorrelationData correlationData) throws AmqpException;
208+
void convertAndSend(@Nullable String exchange, @Nullable String routingKey, Object message,
209+
MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData)
210+
throws AmqpException;
208211

209212
/**
210213
* Basic RPC pattern with conversion. Send a Java object converted to a message to a
211214
* default exchange with a default routing key and attempt to receive a response,
212215
* converting that to a Java object. Implementations will normally set the reply-to
213216
* header to an exclusive queue and wait up for some time limited by a timeout.
214-
*
215217
* @param message a message to send.
216218
* @param correlationData data to correlate publisher confirms.
217219
* @return the response if there is one
218220
* @throws AmqpException if there is a problem
219221
*/
220222
@Nullable
221-
Object convertSendAndReceive(Object message, CorrelationData correlationData) throws AmqpException;
223+
Object convertSendAndReceive(Object message, @Nullable CorrelationData correlationData) throws AmqpException;
222224

223225
/**
224226
* Basic RPC pattern with conversion. Send a Java object converted to a message to a
@@ -233,15 +235,14 @@ void convertAndSend(String exchange, String routingKey, Object message, MessageP
233235
* @throws AmqpException if there is a problem
234236
*/
235237
@Nullable
236-
Object convertSendAndReceive(String routingKey, Object message, CorrelationData correlationData)
238+
Object convertSendAndReceive(@Nullable String routingKey, Object message, @Nullable CorrelationData correlationData)
237239
throws AmqpException;
238240

239241
/**
240242
* Basic RPC pattern with conversion. Send a Java object converted to a message to a
241243
* specific exchange with a specific routing key and attempt to receive a response,
242244
* converting that to a Java object. Implementations will normally set the reply-to
243245
* header to an exclusive queue and wait up for some time limited by a timeout.
244-
*
245246
* @param exchange the name of the exchange
246247
* @param routingKey the routing key
247248
* @param message a message to send
@@ -250,15 +251,14 @@ Object convertSendAndReceive(String routingKey, Object message, CorrelationData
250251
* @throws AmqpException if there is a problem
251252
*/
252253
@Nullable
253-
Object convertSendAndReceive(String exchange, String routingKey, Object message,
254-
CorrelationData correlationData) throws AmqpException;
254+
Object convertSendAndReceive(@Nullable String exchange, @Nullable String routingKey, Object message,
255+
@Nullable CorrelationData correlationData) throws AmqpException;
255256

256257
/**
257258
* Basic RPC pattern with conversion. Send a Java object converted to a message to a
258259
* default exchange with a default routing key and attempt to receive a response,
259260
* converting that to a Java object. Implementations will normally set the reply-to
260261
* header to an exclusive queue and wait up for some time limited by a timeout.
261-
*
262262
* @param message a message to send
263263
* @param messagePostProcessor a processor to apply to the message before it is sent
264264
* @param correlationData data to correlate publisher confirms.
@@ -274,7 +274,6 @@ Object convertSendAndReceive(Object message, MessagePostProcessor messagePostPro
274274
* default exchange with a specific routing key and attempt to receive a response,
275275
* converting that to a Java object. Implementations will normally set the reply-to
276276
* header to an exclusive queue and wait up for some time limited by a timeout.
277-
*
278277
* @param routingKey the routing key
279278
* @param message a message to send
280279
* @param messagePostProcessor a processor to apply to the message before it is sent
@@ -283,15 +282,15 @@ Object convertSendAndReceive(Object message, MessagePostProcessor messagePostPro
283282
* @throws AmqpException if there is a problem
284283
*/
285284
@Nullable
286-
Object convertSendAndReceive(String routingKey, Object message,
287-
MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData) throws AmqpException;
285+
Object convertSendAndReceive(@Nullable String routingKey, Object message,
286+
MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData)
287+
throws AmqpException;
288288

289289
/**
290290
* Basic RPC pattern with conversion. Send a Java object converted to a message to a
291291
* specific exchange with a specific routing key and attempt to receive a response,
292292
* converting that to a Java object. Implementations will normally set the reply-to
293293
* header to an exclusive queue and wait up for some time limited by a timeout.
294-
*
295294
* @param exchange the name of the exchange
296295
* @param routingKey the routing key
297296
* @param message a message to send
@@ -301,7 +300,7 @@ Object convertSendAndReceive(String routingKey, Object message,
301300
* @throws AmqpException if there is a problem
302301
*/
303302
@Nullable
304-
Object convertSendAndReceive(String exchange, String routingKey, Object message,
303+
Object convertSendAndReceive(@Nullable String exchange, @Nullable String routingKey, Object message,
305304
@Nullable MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData)
306305
throws AmqpException;
307306

@@ -339,7 +338,7 @@ Object convertSendAndReceive(String exchange, String routingKey, Object message,
339338
* @return the response if there is one
340339
* @throws AmqpException if there is a problem
341340
*/
342-
<T> @Nullable T convertSendAndReceiveAsType(String routingKey, Object message,
341+
<T> @Nullable T convertSendAndReceiveAsType(@Nullable String routingKey, Object message,
343342
@Nullable CorrelationData correlationData, ParameterizedTypeReference<T> responseType) throws AmqpException;
344343

345344
/**
@@ -359,7 +358,7 @@ Object convertSendAndReceive(String exchange, String routingKey, Object message,
359358
* @return the response if there is one
360359
* @throws AmqpException if there is a problem
361360
*/
362-
default <T> @Nullable T convertSendAndReceiveAsType(String exchange, String routingKey, Object message,
361+
default <T> @Nullable T convertSendAndReceiveAsType(@Nullable String exchange, @Nullable String routingKey, Object message,
363362
@Nullable CorrelationData correlationData, ParameterizedTypeReference<T> responseType)
364363
throws AmqpException {
365364

@@ -402,7 +401,7 @@ Object convertSendAndReceive(String exchange, String routingKey, Object message,
402401
* @return the response if there is one
403402
* @throws AmqpException if there is a problem
404403
*/
405-
<T> @Nullable T convertSendAndReceiveAsType(String routingKey, Object message,
404+
<T> @Nullable T convertSendAndReceiveAsType(@Nullable String routingKey, Object message,
406405
@Nullable MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData,
407406
ParameterizedTypeReference<T> responseType) throws AmqpException;
408407

@@ -424,7 +423,7 @@ Object convertSendAndReceive(String exchange, String routingKey, Object message,
424423
* @return the response if there is one
425424
* @throws AmqpException if there is a problem
426425
*/
427-
<T> @Nullable T convertSendAndReceiveAsType(String exchange, String routingKey, Object message,
426+
<T> @Nullable T convertSendAndReceiveAsType(@Nullable String exchange, @Nullable String routingKey, Object message,
428427
@Nullable MessagePostProcessor messagePostProcessor,
429428
@Nullable CorrelationData correlationData,
430429
ParameterizedTypeReference<T> responseType) throws AmqpException;

0 commit comments

Comments
 (0)