Skip to content

Commit 324df85

Browse files
garyrussellartembilan
authored andcommitted
GH-1550: Fix Mono Return Type Detection
Resolves #1550 **cherry-pick to 2.4.x**
1 parent f1dd244 commit 324df85

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/adapter/MonoHandler.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 the original author or authors.
2+
* Copyright 2021-2023 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.
@@ -34,6 +34,10 @@ static boolean isMono(Object result) {
3434
return result instanceof Mono;
3535
}
3636

37+
static boolean isMono(Class<?> resultType) {
38+
return Mono.class.isAssignableFrom(resultType);
39+
}
40+
3741
@SuppressWarnings("unchecked")
3842
static void subscribe(Object returnValue, Consumer<? super Object> success,
3943
Consumer<? super Throwable> failure, Runnable completeConsumer) {

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/annotation/AsyncListenerTests.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2022 the original author or authors.
2+
* Copyright 2018-2023 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.
@@ -104,7 +104,7 @@ public class AsyncListenerTests {
104104
private RabbitListenerEndpointRegistry registry;
105105

106106
@Test
107-
public void testAsyncListener() throws Exception {
107+
public void testAsyncListener(@Autowired RabbitListenerEndpointRegistry registry) throws Exception {
108108
assertThat(this.rabbitTemplate.convertSendAndReceive(this.queue1.getName(), "foo")).isEqualTo("FOO");
109109
RabbitConverterFuture<Object> future = this.asyncTemplate.convertSendAndReceive(this.queue1.getName(), "foo");
110110
assertThat(future.get(10, TimeUnit.SECONDS)).isEqualTo("FOO");
@@ -118,6 +118,10 @@ public void testAsyncListener() throws Exception {
118118
assertThat(this.config.contentTypeId).isEqualTo("java.lang.String");
119119
this.rabbitTemplate.convertAndSend(this.queue4.getName(), "foo");
120120
assertThat(listener.latch4.await(10, TimeUnit.SECONDS));
121+
assertThat(TestUtils.getPropertyValue(registry.getListenerContainer("foo"), "asyncReplies", Boolean.class))
122+
.isTrue();
123+
assertThat(TestUtils.getPropertyValue(registry.getListenerContainer("bar"), "asyncReplies", Boolean.class))
124+
.isTrue();
121125
}
122126

123127
@Test

0 commit comments

Comments
 (0)