Skip to content

Commit 2d20529

Browse files
committed
* Fix language in docs
* Fix Javadocs lines length * Regular `catch` and re-throw in the `CheckedFunction`
1 parent 949fba8 commit 2d20529

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed

spring-integration-core/src/main/java/org/springframework/integration/util/CheckedFunction.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
/**
2222
* A Function-like interface which allows throwing Error.
2323
*
24-
* @param <T> the input type.
25-
* @param <R> the output type.
24+
* @param <T> the input type.
25+
* @param <R> the output type.
2626
*
2727
* @author Artem Bilan
2828
*
@@ -31,22 +31,25 @@
3131
@FunctionalInterface
3232
public interface CheckedFunction<T, R> {
3333

34-
R apply(T t) throws Throwable;
34+
R apply(T t) throws Throwable; // NOSONAR
3535

3636
default Function<T, R> unchecked() {
3737
return t1 -> {
3838
try {
3939
return apply(t1);
4040
}
41-
catch (Throwable t) {
42-
return sneakyThrow(t);
41+
catch (Throwable t) { // NOSONAR
42+
if (t instanceof RuntimeException runtimeException) {
43+
throw runtimeException;
44+
}
45+
else if (t instanceof Error error) {
46+
throw error;
47+
}
48+
else {
49+
throw new IllegalStateException(t);
50+
}
4351
}
4452
};
4553
}
4654

47-
@SuppressWarnings("unchecked")
48-
private static <T extends Throwable, R> R sneakyThrow(Throwable t) throws T {
49-
throw (T) t;
50-
}
51-
5255
}

spring-integration-jms/src/main/java/org/springframework/integration/jms/ChannelPublishingJmsMessageListener.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,9 @@ public void setDestinationResolver(DestinationResolver destinationResolver) {
270270
}
271271

272272
/**
273-
* Set a SpEL expression to resolve a 'replyTo' destination from a request {@link jakarta.jms.Message}
274-
* as a root evaluation object if {@link jakarta.jms.Message#getJMSReplyTo()} is null.
273+
* Set a SpEL expression to resolve a 'replyTo' destination from a request
274+
* {@link jakarta.jms.Message} as a root evaluation object
275+
* if {@link jakarta.jms.Message#getJMSReplyTo()} is null.
275276
* @param replyToExpression the SpEL expression for 'replyTo' destination.
276277
* @since 6.1
277278
*/
@@ -436,9 +437,11 @@ else if (replyMessage.getJMSCorrelationID() == null) {
436437

437438
/**
438439
* Determine a reply destination for the given message.
439-
* It will first check the JMS Reply-To {@link Destination} of the supplied request message;
440-
* if that is null, then the configured {@link #replyToExpression} is evaluated (if any), then a
441-
* {@link #resolveDefaultReplyDestination default reply destination} is returned; if this too is null,
440+
* It will first check the JMS Reply-To {@link Destination}
441+
* of the supplied request message;
442+
* if that is null, then the configured {@link #replyToExpression} is evaluated
443+
* (if any), then a{@link #resolveDefaultReplyDestination default reply destination}
444+
* is returned; if this too is null,
442445
* then an {@link InvalidDestinationException} is thrown.
443446
* @param request the original incoming JMS message
444447
* @param session the JMS Session to operate on

src/reference/asciidoc/jms.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,11 @@ Starting with version 5.1, when the endpoint is stopped while the application re
411411
Previously, the connection and consumers remained open.
412412
To revert to the previous behavior, set the `shutdownContainerOnStop` on the `JmsInboundGateway` to `false`.
413413

414-
By default, a `JmsInboundGateway` looks for a `jakarta.jms.Message.getJMSReplyTo()` property in the received message for sending a reply.
414+
By default, the `JmsInboundGateway` looks for a `jakarta.jms.Message.getJMSReplyTo()` property in the received message to determine where to send a reply.
415415
Otherwise, it can be configured with a static `defaultReplyDestination`, or `defaultReplyQueueName` or `defaultReplyTopicName`.
416-
In addition, starting with version 6.1, a `replyToExpression` can be configured on a provided `ChannelPublishingJmsMessageListener` to determine a reply destination dynamically if standard `JMSReplyTo` property cannot be on request.
417-
A received `jakarta.jms.Message` is used a root evaluation context object.
418-
The following example demonstrates how to use Java DSL API to configure an inbound JMS gateway for custom reply destination resolved from request message:
416+
In addition, starting with version 6.1, a `replyToExpression` can be configured on a provided `ChannelPublishingJmsMessageListener` to determine the reply destination dynamically, if the standard `JMSReplyTo` property is `null` on the request.
417+
The received `jakarta.jms.Message` is used the root evaluation context object.
418+
The following example demonstrates how to use Java DSL API to configure an inbound JMS gateway with a custom reply destination resolved from the request message:
419419

420420
====
421421
[source,java]

src/reference/asciidoc/whats-new.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ See <<./web-sockets.adoc#web-socket-overview, WebSocket Overview>> for more info
3636
[[x6.1-jms]]
3737
=== JMS Changes
3838

39-
A `JmsInboundGateway`, via its `ChannelPublishingJmsMessageListener`, can now be configured with a `replyToExpression` to resolve a reply destination against request message at runtime.
39+
The `JmsInboundGateway`, via its `ChannelPublishingJmsMessageListener`, can now be configured with a `replyToExpression` to resolve a reply destination against the request message at runtime.
4040
See <<./jms.adoc#jms-inbound-gateway, JMS Inbound Gateway>> for more information.

0 commit comments

Comments
 (0)