Remove unnecessary method.isAccessible() invocation
Closes gh-32548
This commit is contained in:
@@ -115,7 +115,7 @@ public abstract class CoroutinesUtils {
|
||||
Assert.isTrue(KotlinDetector.isSuspendingFunction(method), "Method must be a suspending function");
|
||||
KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method);
|
||||
Assert.notNull(function, () -> "Failed to get Kotlin function for method: " + method);
|
||||
if (method.isAccessible() && !KCallablesJvm.isAccessible(function)) {
|
||||
if (!KCallablesJvm.isAccessible(function)) {
|
||||
KCallablesJvm.setAccessible(function, true);
|
||||
}
|
||||
Mono<Object> mono = MonoKt.mono(context, (scope, continuation) -> {
|
||||
|
||||
@@ -93,6 +93,17 @@ class CoroutinesUtilsTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun invokePrivateSuspendingFunction() {
|
||||
val method = CoroutinesUtilsTests::class.java.getDeclaredMethod("privateSuspendingFunction", String::class.java, Continuation::class.java)
|
||||
val publisher = CoroutinesUtils.invokeSuspendingFunction(method, this, "foo")
|
||||
Assertions.assertThat(publisher).isInstanceOf(Mono::class.java)
|
||||
StepVerifier.create(publisher)
|
||||
.expectNext("foo")
|
||||
.expectComplete()
|
||||
.verify()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun invokeNonSuspendingFunction() {
|
||||
val method = CoroutinesUtilsTests::class.java.getDeclaredMethod("nonSuspendingFunction", String::class.java)
|
||||
@@ -252,6 +263,11 @@ class CoroutinesUtilsTests {
|
||||
return value
|
||||
}
|
||||
|
||||
private suspend fun privateSuspendingFunction(value: String): String {
|
||||
delay(1)
|
||||
return value
|
||||
}
|
||||
|
||||
suspend fun suspendingFunctionWithNullable(value: String?): String? {
|
||||
delay(1)
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user