Refine Coroutines annotated controller support

This commit refines Coroutines annotated controller support
by considering Kotlin Unit as Java void and using the right
ReactiveAdapter to support all use cases, including suspending
functions that return Flow (usual when using APIs like WebClient).

It also fixes RSocket fire and forget handling and adds related tests
for that use case.

Closes gh-24057
Closes gh-23866
This commit is contained in:
Sébastien Deleuze
2019-11-22 12:11:07 +01:00
parent 21b2fc1f01
commit 712eac2915
5 changed files with 93 additions and 21 deletions

View File

@@ -30,6 +30,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.function.Predicate;
import kotlin.Unit;
import kotlin.reflect.KFunction;
import kotlin.reflect.KParameter;
import kotlin.reflect.jvm.ReflectJvmMapping;
@@ -929,6 +930,9 @@ public class MethodParameter {
KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method);
if (function != null && function.isSuspend()) {
Type paramType = ReflectJvmMapping.getJavaType(function.getReturnType());
if (paramType == Unit.class) {
paramType = void.class;
}
return ResolvableType.forType(paramType).resolve(method.getReturnType());
}
}