Skip to content

Commit 8cb9018

Browse files
committed
Merge branch '6.2.x'
# Conflicts: # spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java # spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java # spring-messaging/src/main/java/org/springframework/messaging/core/AbstractDestinationResolvingMessagingTemplate.java # spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessageReceivingTemplate.java # spring-messaging/src/main/java/org/springframework/messaging/core/AbstractMessagingTemplate.java # spring-messaging/src/main/java/org/springframework/messaging/core/MessageRequestReplyOperations.java # spring-messaging/src/main/java/org/springframework/messaging/core/MessageSendingOperations.java
2 parents d510b73 + 65e5c14 commit 8cb9018

File tree

12 files changed

+98
-78
lines changed

12 files changed

+98
-78
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,9 +1199,9 @@ public <T> int[][] batchUpdate(String sql, Collection<T> batchArgs, int batchSiz
11991199
public Map<String, Object> call(CallableStatementCreator csc, List<SqlParameter> declaredParameters)
12001200
throws DataAccessException {
12011201

1202-
final List<SqlParameter> updateCountParameters = new ArrayList<>();
1203-
final List<SqlParameter> resultSetParameters = new ArrayList<>();
1204-
final List<SqlParameter> callParameters = new ArrayList<>();
1202+
List<SqlParameter> updateCountParameters = new ArrayList<>();
1203+
List<SqlParameter> resultSetParameters = new ArrayList<>();
1204+
List<SqlParameter> callParameters = new ArrayList<>();
12051205

12061206
for (SqlParameter parameter : declaredParameters) {
12071207
if (parameter.isResultsParameter()) {

spring-jms/src/main/java/org/springframework/jms/core/JmsMessageOperations.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void convertAndSend(String destinationName, Object payload, @Nullable Map<String
242242
* @param destinationName the name of the target destination
243243
* @param request payload for the request message to send
244244
* @param targetClass the target type to convert the payload of the reply to
245-
* @param requestPostProcessor post process to apply to the request message
245+
* @param requestPostProcessor post-process to apply to the request message
246246
* @return the payload of the reply message, possibly {@code null} if the message
247247
* could not be received, for example due to a timeout
248248
*/
@@ -258,7 +258,7 @@ void convertAndSend(String destinationName, Object payload, @Nullable Map<String
258258
* @param destinationName the name of the target destination
259259
* @param request payload for the request message to send
260260
* @param targetClass the target type to convert the payload of the reply to
261-
* @param requestPostProcessor post process to apply to the request message
261+
* @param requestPostProcessor post-process to apply to the request message
262262
* @return the payload of the reply message, possibly {@code null} if the message
263263
* could not be received, for example due to a timeout
264264
*/

spring-jms/src/main/java/org/springframework/jms/support/destination/JmsDestinationAccessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public abstract class JmsDestinationAccessor extends JmsAccessor {
6969
* @see org.springframework.jms.support.destination.JndiDestinationResolver
7070
*/
7171
public void setDestinationResolver(DestinationResolver destinationResolver) {
72-
Assert.notNull(destinationResolver, "'destinationResolver' must not be null");
72+
Assert.notNull(destinationResolver, "DestinationResolver must not be null");
7373
this.destinationResolver = destinationResolver;
7474
}
7575

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

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.jspecify.annotations.Nullable;
2222

2323
import org.springframework.messaging.Message;
24+
import org.springframework.messaging.MessagingException;
2425
import org.springframework.util.Assert;
2526

2627
/**
@@ -64,77 +65,85 @@ public void setDestinationResolver(@Nullable DestinationResolver<D> destinationR
6465
return this.destinationResolver;
6566
}
6667

68+
protected final D resolveDestination(String destinationName) throws DestinationResolutionException {
69+
Assert.state(this.destinationResolver != null,
70+
"DestinationResolver is required to resolve destination names");
71+
return this.destinationResolver.resolveDestination(destinationName);
72+
}
73+
6774

6875
@Override
69-
public void send(String destinationName, Message<?> message) {
76+
public void send(String destinationName, Message<?> message) throws MessagingException {
7077
D destination = resolveDestination(destinationName);
7178
doSend(destination, message);
7279
}
7380

74-
protected final D resolveDestination(String destinationName) {
75-
76-
Assert.state(this.destinationResolver != null, "DestinationResolver is required to resolve destination names");
77-
return this.destinationResolver.resolveDestination(destinationName);
78-
}
79-
8081
@Override
81-
public <T> void convertAndSend(String destinationName, T payload) {
82+
public <T> void convertAndSend(String destinationName, T payload) throws MessagingException {
8283
convertAndSend(destinationName, payload, null, null);
8384
}
8485

8586
@Override
86-
public <T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers) {
87+
public <T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers)
88+
throws MessagingException {
89+
8790
convertAndSend(destinationName, payload, headers, null);
8891
}
8992

9093
@Override
91-
public <T> void convertAndSend(String destinationName, T payload, @Nullable MessagePostProcessor postProcessor) {
94+
public <T> void convertAndSend(String destinationName, T payload, @Nullable MessagePostProcessor postProcessor)
95+
throws MessagingException {
96+
9297
convertAndSend(destinationName, payload, null, postProcessor);
9398
}
9499

95100
@Override
96-
public <T> void convertAndSend(String destinationName, T payload,
97-
@Nullable Map<String, Object> headers, @Nullable MessagePostProcessor postProcessor) {
101+
public <T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers,
102+
@Nullable MessagePostProcessor postProcessor) throws MessagingException {
98103

99104
D destination = resolveDestination(destinationName);
100105
super.convertAndSend(destination, payload, headers, postProcessor);
101106
}
102107

103108
@Override
104-
public @Nullable Message<?> receive(String destinationName) {
109+
public @Nullable Message<?> receive(String destinationName) throws MessagingException {
105110
D destination = resolveDestination(destinationName);
106111
return super.receive(destination);
107112
}
108113

109114
@Override
110-
public <T> @Nullable T receiveAndConvert(String destinationName, Class<T> targetClass) {
115+
public <T> @Nullable T receiveAndConvert(String destinationName, Class<T> targetClass) throws MessagingException {
111116
D destination = resolveDestination(destinationName);
112117
return super.receiveAndConvert(destination, targetClass);
113118
}
114119

115120
@Override
116-
public @Nullable Message<?> sendAndReceive(String destinationName, Message<?> requestMessage) {
121+
public @Nullable Message<?> sendAndReceive(String destinationName, Message<?> requestMessage)
122+
throws MessagingException {
123+
117124
D destination = resolveDestination(destinationName);
118125
return super.sendAndReceive(destination, requestMessage);
119126
}
120127

121128
@Override
122-
public <T> @Nullable T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass) {
129+
public <T> @Nullable T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass)
130+
throws MessagingException {
131+
123132
D destination = resolveDestination(destinationName);
124133
return super.convertSendAndReceive(destination, request, targetClass);
125134
}
126135

127136
@Override
128137
public <T> @Nullable T convertSendAndReceive(String destinationName, Object request,
129-
@Nullable Map<String, Object> headers, Class<T> targetClass) {
138+
@Nullable Map<String, Object> headers, Class<T> targetClass) throws MessagingException {
130139

131140
D destination = resolveDestination(destinationName);
132141
return super.convertSendAndReceive(destination, request, headers, targetClass);
133142
}
134143

135144
@Override
136145
public <T> @Nullable T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass,
137-
@Nullable MessagePostProcessor postProcessor) {
146+
@Nullable MessagePostProcessor postProcessor) throws MessagingException {
138147

139148
D destination = resolveDestination(destinationName);
140149
return super.convertSendAndReceive(destination, request, targetClass, postProcessor);
@@ -143,7 +152,7 @@ public <T> void convertAndSend(String destinationName, T payload,
143152
@Override
144153
public <T> @Nullable T convertSendAndReceive(String destinationName, Object request,
145154
@Nullable Map<String, Object> headers, Class<T> targetClass,
146-
@Nullable MessagePostProcessor postProcessor) {
155+
@Nullable MessagePostProcessor postProcessor) throws MessagingException {
147156

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

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.jspecify.annotations.Nullable;
2020

2121
import org.springframework.messaging.Message;
22+
import org.springframework.messaging.MessagingException;
2223
import org.springframework.messaging.converter.MessageConversionException;
2324
import org.springframework.messaging.converter.MessageConverter;
2425

@@ -36,31 +37,22 @@ public abstract class AbstractMessageReceivingTemplate<D> extends AbstractMessag
3637
implements MessageReceivingOperations<D> {
3738

3839
@Override
39-
public @Nullable Message<?> receive() {
40+
public @Nullable Message<?> receive() throws MessagingException {
4041
return doReceive(getRequiredDefaultDestination());
4142
}
4243

4344
@Override
44-
public @Nullable Message<?> receive(D destination) {
45+
public @Nullable Message<?> receive(D destination) throws MessagingException {
4546
return doReceive(destination);
4647
}
4748

48-
/**
49-
* Actually receive a message from the given destination.
50-
* @param destination the target destination
51-
* @return the received message, possibly {@code null} if the message could not
52-
* be received, for example due to a timeout
53-
*/
54-
protected abstract @Nullable Message<?> doReceive(D destination);
55-
56-
5749
@Override
58-
public <T> @Nullable T receiveAndConvert(Class<T> targetClass) {
50+
public <T> @Nullable T receiveAndConvert(Class<T> targetClass) throws MessagingException {
5951
return receiveAndConvert(getRequiredDefaultDestination(), targetClass);
6052
}
6153

6254
@Override
63-
public <T> @Nullable T receiveAndConvert(D destination, Class<T> targetClass) {
55+
public <T> @Nullable T receiveAndConvert(D destination, Class<T> targetClass) throws MessagingException {
6456
Message<?> message = doReceive(destination);
6557
if (message != null) {
6658
return doConvert(message, targetClass);
@@ -87,4 +79,12 @@ public abstract class AbstractMessageReceivingTemplate<D> extends AbstractMessag
8779
return value;
8880
}
8981

82+
/**
83+
* Actually receive a message from the given destination.
84+
* @param destination the target destination
85+
* @return the received message, possibly {@code null} if the message could not
86+
* be received, for example due to a timeout
87+
*/
88+
protected abstract @Nullable Message<?> doReceive(D destination);
89+
9090
}

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ public void send(D destination, Message<?> message) {
108108
doSend(destination, message);
109109
}
110110

111-
protected abstract void doSend(D destination, Message<?> message);
112-
113-
114111
@Override
115112
public void convertAndSend(Object payload) throws MessagingException {
116113
convertAndSend(payload, null, null);
@@ -162,6 +159,7 @@ public void convertAndSend(D destination, Object payload, @Nullable Map<String,
162159
send(destination, message);
163160
}
164161

162+
165163
/**
166164
* Convert the given Object to serialized form, possibly using a
167165
* {@link MessageConverter}, wrap it as a message with the given
@@ -209,4 +207,11 @@ protected Message<?> doConvert(Object payload, @Nullable Map<String, Object> hea
209207
return headers;
210208
}
211209

210+
/**
211+
* Actually send the given message to the given destination.
212+
* @param destination the target destination
213+
* @param message the message to send
214+
*/
215+
protected abstract void doSend(D destination, Message<?> message);
216+
212217
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ public abstract class AbstractMessagingTemplate<D> extends AbstractMessageReceiv
104104
}
105105

106106

107+
/**
108+
* Actually send the given request message to the given destination and
109+
* receive a reply message for it.
110+
* @param destination the target destination
111+
* @param requestMessage the message to send
112+
* @return the received reply, possibly {@code null} if the
113+
* message could not be received, for example due to a timeout
114+
*/
107115
protected abstract @Nullable Message<?> doSendAndReceive(D destination, Message<?> requestMessage);
108116

109117
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ public interface DestinationResolvingMessageRequestReplyOperations<D> extends Me
8080
* Resolve the given destination name, convert the payload request Object
8181
* to serialized form, possibly using a
8282
* {@link org.springframework.messaging.converter.MessageConverter},
83-
* wrap it as a message, apply the given post process, and send the resulting
83+
* wrap it as a message, apply the given post-process, and send the resulting
8484
* message to the resolved destination, then receive a reply and convert its
8585
* body to the specified target class.
8686
* @param destinationName the name of the target destination
8787
* @param request the payload for the request message to send
8888
* @param targetClass the target class to convert the payload of the reply to
89-
* @param requestPostProcessor post process for the request message
89+
* @param requestPostProcessor post-process for the request message
9090
* @return the converted payload of the reply message, possibly {@code null} if
9191
* the message could not be received, for example due to a timeout
9292
*/
@@ -97,14 +97,14 @@ public interface DestinationResolvingMessageRequestReplyOperations<D> extends Me
9797
* Resolve the given destination name, convert the payload request Object
9898
* to serialized form, possibly using a
9999
* {@link org.springframework.messaging.converter.MessageConverter},
100-
* wrap it as a message with the given headers, apply the given post process,
100+
* wrap it as a message with the given headers, apply the given post-process,
101101
* and send the resulting message to the resolved destination, then receive
102102
* a reply and convert its body to the specified target class.
103103
* @param destinationName the name of the target destination
104104
* @param request the payload for the request message to send
105105
* @param headers the headers for the request message to send
106106
* @param targetClass the target class to convert the payload of the reply to
107-
* @param requestPostProcessor post process for the request message
107+
* @param requestPostProcessor post-process for the request message
108108
* @return the converted payload of the reply message, possibly {@code null} if
109109
* the message could not be received, for example due to a timeout
110110
*/

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ <T> void convertAndSend(String destinationName, T payload, @Nullable Map<String,
6969
* Resolve the given destination name to a destination, convert the payload
7070
* Object to serialized form, possibly using a
7171
* {@link org.springframework.messaging.converter.MessageConverter},
72-
* wrap it as a message, apply the given post processor, and send the resulting
72+
* wrap it as a message, apply the given post-processor, and send the resulting
7373
* message to the resolved destination.
7474
* @param destinationName the destination name to resolve
7575
* @param payload the Object to use as payload
76-
* @param postProcessor the post processor to apply to the message
76+
* @param postProcessor the post-processor to apply to the message
7777
*/
7878
<T> void convertAndSend(String destinationName, T payload, @Nullable MessagePostProcessor postProcessor)
7979
throws MessagingException;
@@ -82,12 +82,12 @@ <T> void convertAndSend(String destinationName, T payload, @Nullable MessagePost
8282
* Resolve the given destination name to a destination, convert the payload
8383
* Object to serialized form, possibly using a
8484
* {@link org.springframework.messaging.converter.MessageConverter},
85-
* wrap it as a message with the given headers, apply the given post processor,
85+
* wrap it as a message with the given headers, apply the given post-processor,
8686
* and send the resulting message to the resolved destination.
8787
* @param destinationName the destination name to resolve
8888
* @param payload the Object to use as payload
8989
* @param headers the headers for the message to send
90-
* @param postProcessor the post processor to apply to the message
90+
* @param postProcessor the post-processor to apply to the message
9191
*/
9292
<T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers,
9393
@Nullable MessagePostProcessor postProcessor) throws MessagingException;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public interface MessageRequestReplyOperations<D> {
116116
* target class.
117117
* @param request payload for the request message to send
118118
* @param targetClass the target type to convert the payload of the reply to
119-
* @param requestPostProcessor post process to apply to the request message
119+
* @param requestPostProcessor post-process to apply to the request message
120120
* @return the payload of the reply message, possibly {@code null} if the message
121121
* could not be received, for example due to a timeout
122122
*/
@@ -133,7 +133,7 @@ public interface MessageRequestReplyOperations<D> {
133133
* @param destination the target destination
134134
* @param request payload for the request message to send
135135
* @param targetClass the target type to convert the payload of the reply to
136-
* @param requestPostProcessor post process to apply to the request message
136+
* @param requestPostProcessor post-process to apply to the request message
137137
* @return the payload of the reply message, possibly {@code null} if the message
138138
* could not be received, for example due to a timeout
139139
*/
@@ -148,7 +148,7 @@ public interface MessageRequestReplyOperations<D> {
148148
* the reply and convert its body of the given target class.
149149
* @param request payload for the request message to send
150150
* @param targetClass the target type to convert the payload of the reply to
151-
* @param requestPostProcessor post process to apply to the request message
151+
* @param requestPostProcessor post-process to apply to the request message
152152
* @return the payload of the reply message, possibly {@code null} if the message
153153
* could not be received, for example due to a timeout
154154
* @since 7.0
@@ -166,7 +166,7 @@ public interface MessageRequestReplyOperations<D> {
166166
* @param destination the target destination
167167
* @param request payload for the request message to send
168168
* @param targetClass the target type to convert the payload of the reply to
169-
* @param requestPostProcessor post process to apply to the request message
169+
* @param requestPostProcessor post-process to apply to the request message
170170
* @return the payload of the reply message, possibly {@code null} if the message
171171
* could not be received, for example due to a timeout
172172
*/

0 commit comments

Comments
 (0)