You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In what version(s) of Spring AMQP are you seeing this issue?
3.0.9(for my project) & 3.2.3(latest version for demo)
Describe the bug
It is known in #1210 this library added a kotlin coroutine support. This is fine as long as the function doesn't return a value. But as soon as our function returns a value the return value type resolver in AbstractAdaptableMessageListener.asyncSuccess throws an error because it gets the invocation result type of java.lang.Object which can't be cast to ParameterizedType.
To Reproduce
A kotlin coroutine with a return value of String? annotated with @RabbitListener
Expected behavior
The return type must be correctly set in InvocationResult
Fixes: #2638
The `AbstractAdaptableMessageListener.asyncSuccess()` assumes only `Mono` & `CompletableFuture` return types.
With Kotlin `suspend` it is just plain `Object`.
* Fix `AbstractAdaptableMessageListener.asyncSuccess()` to check if `returnType` is not simple `Object.class`
before going deep for its generic actual argument.
(cherry picked from commit 08ead3b)
I've been following the discussion on Kotlin suspend function return types and appreciate the fixes and updates made. I am curious if similar support or modifications have been considered for the KafkaListener in the context of handling Kafka messages with Kotlin coroutines? Specifically, is there any ongoing work or planned updates to ensure that KafkaListeners can handle return types correctly when used with Kotlin suspend functions?
Thank you for your efforts and any information you can provide on this matter.
In what version(s) of Spring AMQP are you seeing this issue?
3.0.9(for my project) & 3.2.3(latest version for demo)
Describe the bug
It is known in #1210 this library added a kotlin coroutine support. This is fine as long as the function doesn't return a value. But as soon as our function returns a value the return value type resolver in
AbstractAdaptableMessageListener.asyncSuccess
throws an error because it gets the invocation result type ofjava.lang.Object
which can't be cast toParameterizedType
.To Reproduce
A kotlin coroutine with a return value of
String?
annotated with@RabbitListener
Expected behavior
The return type must be correctly set in InvocationResult
Sample
https://github.com/abelmulq/spring-amqp-2638-sample
The text was updated successfully, but these errors were encountered: