Peter
05/02/2022, 6:01 PMjava.lang.UnsupportedOperationException: This class is an internal synthetic class generated by the Kotlin compiler, such as an anonymous class for a lambda, a SAM wrapper, a callable reference, etc. It's not a Kotlin class or interface, so the reflection library has no idea what declarations it has. Please use Java reflection to inspect this class: class com.xxx.SessionManagementKt$swapUserSession$1$1
at kotlin.reflect.jvm.internal.KClassImpl.reportUnresolvedClass(KClassImpl.kt:316)
at kotlin.reflect.jvm.internal.KClassImpl.access$reportUnresolvedClass(KClassImpl.kt:44)
...
at kotlin.jvm.internal.CallableReference.getTypeParameters(CallableReference.java:156)
at kotlin.reflect.jvm.internal.ReflectionFactoryImpl.typeParameter(ReflectionFactoryImpl.java:134)
at kotlin.jvm.internal.Reflection.typeParameter(Reflection.java:174)
at com.xxx.SessionManagement$swapUserSession$1$1.invokeSuspend(SessionManagement.kt:162)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.continuations.generic.SuspendMonadContinuation.resumeWith(SuspendingComputation.kt:54)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.ktor.server.netty.EventLoopGroupProxy$Companion.create$lambda-1$lambda-0(NettyApplicationEngine.kt:260)
fun <A, B, C>Route.swapUserSession(...) {
authenticate("auth-basic") {
post("/internal/session") {
...
doThing()
}
}
}
suspend fun <A, B, C>doThing(): Bla<A>
doThing()
actually succeeds and returns a valueAleksei Tirman [JB]
05/08/2022, 3:39 PMfun main() {
embeddedServer(Netty, port = 3333) {
install(Authentication) {
basic("auth-basic") {
validate {
UserIdPrincipal("123")
}
}
}
routing {
swapUserSession<Int, Int, Int>()
}
}.start(wait = true)
}
fun <A, B, C> Route.swapUserSession() {
authenticate("auth-basic") {
post("/") {
//...
doThing<A,B,C>()
}
}
}
suspend fun <A, B, C>doThing(): Bla<A> {
return Bla<Int>() as Bla<A>
}
class Bla<T> {
}