From c55606ed08609653c537c6da6c8900fc8ea07513 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Thu, 19 May 2022 13:33:17 +0200 Subject: [PATCH] Recognize Kotlin coroutines in isAsyncVoidReturnType This commit makes sure that Kotlin coroutines are correctly identified by InvocableHandlerMethod::isAsyncVoidReturnType. Closes gh-26829 --- .../reactive/InvocableHandlerMethod.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethod.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethod.java index aad9384af2..18f17b5a27 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethod.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethod.java @@ -205,15 +205,17 @@ public class InvocableHandlerMethod extends HandlerMethod { if (reactiveAdapter.isNoValue()) { return true; } - Type parameterType = returnType.getGenericParameterType(); - if (parameterType instanceof ParameterizedType) { - ParameterizedType type = (ParameterizedType) parameterType; - if (type.getActualTypeArguments().length == 1) { - return Void.class.equals(type.getActualTypeArguments()[0]); - } + } + Type parameterType = returnType.getGenericParameterType(); + if (parameterType instanceof ParameterizedType) { + ParameterizedType type = (ParameterizedType) parameterType; + if (type.getActualTypeArguments().length == 1) { + return Void.class.equals(type.getActualTypeArguments()[0]); } } - return false; + Method method = returnType.getMethod(); + return method != null && KotlinDetector.isSuspendingFunction(method) && + Void.TYPE.equals(returnType.getParameterType()); } }