From bd27ddf83afc0e4432e7c6b0d7256dc85ad2fa55 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 19 Mar 2024 10:05:32 +0100 Subject: [PATCH] Polishing (aligned with main) --- .../java/org/springframework/core/CoroutinesUtils.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java b/spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java index 8ba870d07a..34e2c6a975 100644 --- a/spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java +++ b/spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java @@ -19,7 +19,6 @@ package org.springframework.core; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Map; -import java.util.Objects; import kotlin.Unit; import kotlin.coroutines.CoroutineContext; @@ -93,8 +92,7 @@ public abstract class CoroutinesUtils { * @return the method invocation result as reactive stream * @throws IllegalArgumentException if {@code method} is not a suspending function */ - public static Publisher invokeSuspendingFunction(Method method, Object target, - Object... args) { + public static Publisher invokeSuspendingFunction(Method method, Object target, Object... args) { return invokeSuspendingFunction(Dispatchers.getUnconfined(), method, target, args); } @@ -115,7 +113,8 @@ public abstract class CoroutinesUtils { CoroutineContext context, Method method, @Nullable Object target, Object... args) { Assert.isTrue(KotlinDetector.isSuspendingFunction(method), "Method must be a suspending function"); - KFunction function = Objects.requireNonNull(ReflectJvmMapping.getKotlinFunction(method)); + KFunction function = ReflectJvmMapping.getKotlinFunction(method); + Assert.notNull(function, () -> "Failed to get Kotlin function for method: " + method); if (method.isAccessible() && !KCallablesJvm.isAccessible(function)) { KCallablesJvm.setAccessible(function, true); }