Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for Kotlin value class in annotated services (#5449)
Motivation: The following error is raised when Kotlin value class is declared in the parameters of annotated services. ``` INFO: object is not an instance of declaring class java.lang.IllegalArgumentException: object is not an instance of declaring class at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at kotlin.reflect.jvm.internal.calls.InlineClassAwareCaller.call(InlineClassAwareCaller.kt:135) at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:107) at kotlin.reflect.full.KCallables.callSuspend(KCallables.kt:56) at com.linecorp.armeria.internal.common.kotlin.ArmeriaCoroutineUtil$callKotlinSuspendingMethod$future$1.invokeSuspend(ArmeriaCoroutineUtil.kt:54) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:833) ``` See #5294 for the details. Modifications: - Add a workaround to wrap a value with the closing class. - The workaround is forked from Spring Framework and modified. - https://github.com/spring-projects/spring-framework/blob/91b9a7537138d7de478c3229069acfe946adcb3a/spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java#L309 Result: - You can now use Kotlin value classes in annotated services. - Fixes: #5294
- Loading branch information