Skip to content

Commit 7e25127

Browse files
committed
Consistent nullability of headers Map and MessagePostProcessor
Issue: SPR-15670
1 parent 4a21fb2 commit 7e25127

5 files changed

+36
-26
lines changed

spring-messaging/src/main/java/org/springframework/messaging/core/AbstractDestinationResolvingMessagingTemplate.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -80,17 +80,19 @@ public <T> void convertAndSend(String destinationName, T payload) {
8080
}
8181

8282
@Override
83-
public <T> void convertAndSend(String destinationName, T payload, Map<String, Object> headers) {
83+
public <T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers) {
8484
convertAndSend(destinationName, payload, headers, null);
8585
}
8686

8787
@Override
88-
public <T> void convertAndSend(String destinationName, T payload, MessagePostProcessor postProcessor) {
88+
public <T> void convertAndSend(String destinationName, T payload, @Nullable MessagePostProcessor postProcessor) {
8989
convertAndSend(destinationName, payload, null, postProcessor);
9090
}
9191

9292
@Override
93-
public <T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers, @Nullable MessagePostProcessor postProcessor) {
93+
public <T> void convertAndSend(String destinationName, T payload,
94+
@Nullable Map<String, Object> headers, @Nullable MessagePostProcessor postProcessor) {
95+
9496
D destination = resolveDestination(destinationName);
9597
super.convertAndSend(destination, payload, headers, postProcessor);
9698
}
@@ -120,24 +122,25 @@ public <T> T convertSendAndReceive(String destinationName, Object request, Class
120122
}
121123

122124
@Override
123-
public <T> T convertSendAndReceive(String destinationName, Object request, Map<String, Object> headers,
124-
Class<T> targetClass) {
125+
public <T> T convertSendAndReceive(String destinationName, Object request,
126+
@Nullable Map<String, Object> headers, Class<T> targetClass) {
125127

126128
D destination = resolveDestination(destinationName);
127129
return super.convertSendAndReceive(destination, request, headers, targetClass);
128130
}
129131

130132
@Override
131133
public <T> T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass,
132-
MessagePostProcessor postProcessor) {
134+
@Nullable MessagePostProcessor postProcessor) {
133135

134136
D destination = resolveDestination(destinationName);
135137
return super.convertSendAndReceive(destination, request, targetClass, postProcessor);
136138
}
137139

138140
@Override
139-
public <T> T convertSendAndReceive(String destinationName, Object request, Map<String, Object> headers,
140-
Class<T> targetClass, MessagePostProcessor postProcessor) {
141+
public <T> T convertSendAndReceive(String destinationName, Object request,
142+
@Nullable Map<String, Object> headers, Class<T> targetClass,
143+
@Nullable MessagePostProcessor postProcessor) {
141144

142145
D destination = resolveDestination(destinationName);
143146
return super.convertSendAndReceive(destination, request, headers, targetClass, postProcessor);

spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessagingTemplate.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,16 @@ public <T> T convertSendAndReceive(D destination, Object request, Class<T> targe
5858
}
5959

6060
@Override
61-
public <T> T convertSendAndReceive(D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass) {
61+
public <T> T convertSendAndReceive(
62+
D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass) {
63+
6264
return convertSendAndReceive(destination, request, headers, targetClass, null);
6365
}
6466

6567
@Override
66-
public <T> T convertSendAndReceive(Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) {
68+
public <T> T convertSendAndReceive(
69+
Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) {
70+
6771
return convertSendAndReceive(getRequiredDefaultDestination(), request, targetClass, postProcessor);
6872
}
6973

spring-messaging/src/main/java/org/springframework/messaging/core/DestinationResolvingMessageRequestReplyOperations.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -74,8 +74,8 @@ <T> T convertSendAndReceive(String destinationName, Object request, Class<T> tar
7474
* the message could not be received, for example due to a timeout
7575
*/
7676
@Nullable
77-
<T> T convertSendAndReceive(String destinationName, Object request, Map<String, Object> headers,
78-
Class<T> targetClass) throws MessagingException;
77+
<T> T convertSendAndReceive(String destinationName, Object request,
78+
@Nullable Map<String, Object> headers, Class<T> targetClass) throws MessagingException;
7979

8080
/**
8181
* Resolve the given destination name, convert the payload request Object
@@ -92,8 +92,8 @@ <T> T convertSendAndReceive(String destinationName, Object request, Map<String,
9292
* the message could not be received, for example due to a timeout
9393
*/
9494
@Nullable
95-
<T> T convertSendAndReceive(String destinationName, Object request,
96-
Class<T> targetClass, MessagePostProcessor requestPostProcessor) throws MessagingException;
95+
<T> T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass,
96+
@Nullable MessagePostProcessor requestPostProcessor) throws MessagingException;
9797

9898
/**
9999
* Resolve the given destination name, convert the payload request Object
@@ -111,7 +111,7 @@ <T> T convertSendAndReceive(String destinationName, Object request,
111111
* the message could not be received, for example due to a timeout
112112
*/
113113
@Nullable
114-
<T> T convertSendAndReceive(String destinationName, Object request, Map<String, Object> headers,
115-
Class<T> targetClass, MessagePostProcessor requestPostProcessor) throws MessagingException;
114+
<T> T convertSendAndReceive(String destinationName, Object request, @Nullable Map<String, Object> headers,
115+
Class<T> targetClass, @Nullable MessagePostProcessor requestPostProcessor) throws MessagingException;
116116

117117
}

spring-messaging/src/main/java/org/springframework/messaging/core/DestinationResolvingMessageSendingOperations.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -60,7 +60,7 @@ public interface DestinationResolvingMessageSendingOperations<D> extends Message
6060
* @param payload the Object to use as payload
6161
* @param headers headers for the message to send
6262
*/
63-
<T> void convertAndSend(String destinationName, T payload, Map<String, Object> headers)
63+
<T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers)
6464
throws MessagingException;
6565

6666
/**
@@ -73,7 +73,7 @@ <T> void convertAndSend(String destinationName, T payload, Map<String, Object> h
7373
* @param payload the Object to use as payload
7474
* @param postProcessor the post processor to apply to the message
7575
*/
76-
<T> void convertAndSend(String destinationName, T payload, MessagePostProcessor postProcessor)
76+
<T> void convertAndSend(String destinationName, T payload, @Nullable MessagePostProcessor postProcessor)
7777
throws MessagingException;
7878

7979
/**

spring-messaging/src/main/java/org/springframework/messaging/core/MessageRequestReplyOperations.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -92,7 +92,8 @@ public interface MessageRequestReplyOperations<D> {
9292
* could not be received, for example due to a timeout
9393
*/
9494
@Nullable
95-
<T> T convertSendAndReceive(D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass)
95+
<T> T convertSendAndReceive(
96+
D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass)
9697
throws MessagingException;
9798

9899
/**
@@ -108,7 +109,8 @@ <T> T convertSendAndReceive(D destination, Object request, @Nullable Map<String,
108109
* could not be received, for example due to a timeout
109110
*/
110111
@Nullable
111-
<T> T convertSendAndReceive(Object request, Class<T> targetClass, @Nullable MessagePostProcessor requestPostProcessor)
112+
<T> T convertSendAndReceive(
113+
Object request, Class<T> targetClass, @Nullable MessagePostProcessor requestPostProcessor)
112114
throws MessagingException;
113115

114116
/**
@@ -142,7 +144,8 @@ <T> T convertSendAndReceive(D destination, Object request, Class<T> targetClass,
142144
* could not be received, for example due to a timeout
143145
*/
144146
@Nullable
145-
<T> T convertSendAndReceive(D destination, Object request, @Nullable Map<String, Object> headers,
146-
Class<T> targetClass, @Nullable MessagePostProcessor requestPostProcessor) throws MessagingException;
147+
<T> T convertSendAndReceive(
148+
D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass,
149+
@Nullable MessagePostProcessor requestPostProcessor) throws MessagingException;
147150

148151
}

0 commit comments

Comments
 (0)