GH-1550: Fix Mono Return Type Detection

Resolves https://github.com/spring-projects/spring-amqp/issues/1550

**cherry-pick to 2.4.x**
This commit is contained in:
Gary Russell
2023-01-09 15:23:27 -05:00
committed by Artem Bilan
parent c88a6580d9
commit 87aa29cd02
2 changed files with 11 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2021 the original author or authors.
* Copyright 2021-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +34,10 @@ final class MonoHandler { // NOSONAR - pointless to name it ..Utils|Helper
return result instanceof Mono;
}
static boolean isMono(Class<?> resultType) {
return Mono.class.isAssignableFrom(resultType);
}
@SuppressWarnings("unchecked")
static void subscribe(Object returnValue, Consumer<? super Object> success,
Consumer<? super Throwable> failure, Runnable completeConsumer) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 the original author or authors.
* Copyright 2018-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -104,7 +104,7 @@ public class AsyncListenerTests {
private RabbitListenerEndpointRegistry registry;
@Test
public void testAsyncListener() throws Exception {
public void testAsyncListener(@Autowired RabbitListenerEndpointRegistry registry) throws Exception {
assertThat(this.rabbitTemplate.convertSendAndReceive(this.queue1.getName(), "foo")).isEqualTo("FOO");
RabbitConverterFuture<Object> future = this.asyncTemplate.convertSendAndReceive(this.queue1.getName(), "foo");
assertThat(future.get(10, TimeUnit.SECONDS)).isEqualTo("FOO");
@@ -118,6 +118,10 @@ public class AsyncListenerTests {
assertThat(this.config.contentTypeId).isEqualTo("java.lang.String");
this.rabbitTemplate.convertAndSend(this.queue4.getName(), "foo");
assertThat(listener.latch4.await(10, TimeUnit.SECONDS));
assertThat(TestUtils.getPropertyValue(registry.getListenerContainer("foo"), "asyncReplies", Boolean.class))
.isTrue();
assertThat(TestUtils.getPropertyValue(registry.getListenerContainer("bar"), "asyncReplies", Boolean.class))
.isTrue();
}
@Test