|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2021 the original author or authors. |
|
|
|
|
* Copyright 2002-2022 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. |
|
|
|
|
@ -25,6 +25,7 @@ import kotlin.jvm.JvmClassMappingKt;
@@ -25,6 +25,7 @@ import kotlin.jvm.JvmClassMappingKt;
|
|
|
|
|
import kotlin.reflect.KClassifier; |
|
|
|
|
import kotlin.reflect.KFunction; |
|
|
|
|
import kotlin.reflect.full.KCallables; |
|
|
|
|
import kotlin.reflect.jvm.KCallablesJvm; |
|
|
|
|
import kotlin.reflect.jvm.ReflectJvmMapping; |
|
|
|
|
import kotlinx.coroutines.BuildersKt; |
|
|
|
|
import kotlinx.coroutines.CoroutineStart; |
|
|
|
|
@ -68,8 +69,12 @@ public abstract class CoroutinesUtils {
@@ -68,8 +69,12 @@ public abstract class CoroutinesUtils {
|
|
|
|
|
* Invoke a suspending function and converts it to {@link Mono} or |
|
|
|
|
* {@link Flux}. |
|
|
|
|
*/ |
|
|
|
|
@SuppressWarnings("deprecation") |
|
|
|
|
public static Publisher<?> invokeSuspendingFunction(Method method, Object target, Object... args) { |
|
|
|
|
KFunction<?> function = Objects.requireNonNull(ReflectJvmMapping.getKotlinFunction(method)); |
|
|
|
|
if (method.isAccessible() && !KCallablesJvm.isAccessible(function)) { |
|
|
|
|
KCallablesJvm.setAccessible(function, true); |
|
|
|
|
} |
|
|
|
|
KClassifier classifier = function.getReturnType().getClassifier(); |
|
|
|
|
Mono<Object> mono = MonoKt.mono(Dispatchers.getUnconfined(), (scope, continuation) -> |
|
|
|
|
KCallables.callSuspend(function, getSuspendedFunctionArgs(target, args), continuation)) |
|
|
|
|
|