From 884c7696cebadc877d63d8212e311f9f3489b9fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Tue, 14 Apr 2020 14:56:21 +0200 Subject: [PATCH] Make it possible to run Spring MVC without kotlin-reflect Closes gh-24828 --- .../web/servlet/handler/AbstractHandlerMethodMapping.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java index 9c94758a16b..bfda2d48494 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java @@ -591,8 +591,11 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap public void register(T mapping, Object handler, Method method) { // Assert that the handler method is not a suspending one. - if (KotlinDetector.isKotlinType(method.getDeclaringClass()) && KotlinDelegate.isSuspend(method)) { - throw new IllegalStateException("Unsupported suspending handler method detected: " + method); + if (KotlinDetector.isKotlinType(method.getDeclaringClass())) { + Class[] parameterTypes = method.getParameterTypes(); + if ((parameterTypes.length > 0) && "kotlin.coroutines.Continuation".equals(parameterTypes[parameterTypes.length - 1].getName())) { + throw new IllegalStateException("Unsupported suspending handler method detected: " + method); + } } this.readWriteLock.writeLock().lock(); try {