Closed Rattlyy closed 1 week ago
Hello @Rattlyy! I will check compatibility.
Looks like there is no any problems with the plugin itself.
However, TestApplicationEngine
was changed and tests were affected.
Will try to fix it asap.
Error in 3.0.0-beta-1
routing {
cacheOutput(2.seconds) {
get("/short") {
call.respond(Random.nextInt().toString())
}
}
cacheOutput {
get("/default") {
call.respond(Random.nextInt().toString())
}
}
}
Exception in thread "main" java.lang.IncompatibleClassChangeError: Found interface io.ktor.server.routing.Route, but class was expected
at com.ucasoft.ktor.simpleCache.CacheOutputKt.cacheOutput-hhJSO8g(CacheOutput.kt:13)
at com.ucasoft.ktor.simpleCache.CacheOutputKt.cacheOutput-hhJSO8g$default(CacheOutput.kt:12)
at com.example.plugins.HTTPKt.configureHTTP$lambda$15(HTTP.kt:88)
at io.ktor.server.routing.RoutingKt.routing(Routing.kt:166)
at com.example.plugins.HTTPKt.configureHTTP(HTTP.kt:87)
at com.example.ApplicationKt.module(Application.kt:15)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at kotlin.reflect.jvm.internal.calls.CallerImpl$Method.callMethod(CallerImpl.kt:97)
at kotlin.reflect.jvm.internal.calls.CallerImpl$Method$Static.call(CallerImpl.kt:106)
at kotlin.reflect.jvm.internal.KCallableImpl.callDefaultMethod$kotlin_reflection(KCallableImpl.kt:188)
at kotlin.reflect.jvm.internal.KCallableImpl.callBy(KCallableImpl.kt:111)
at io.ktor.server.engine.internal.CallableUtilsKt.callFunctionWithInjection(CallableUtils.kt:120)
at io.ktor.server.engine.internal.CallableUtilsKt.executeModuleFunction(CallableUtils.kt:36)
at io.ktor.server.engine.EmbeddedServer$launchModuleByName$1.invoke(EmbeddedServerJvm.kt:349)
at io.ktor.server.engine.EmbeddedServer$launchModuleByName$1.invoke(EmbeddedServerJvm.kt:348)
at io.ktor.server.engine.EmbeddedServer.avoidingDoubleStartupFor(EmbeddedServerJvm.kt:373)
at io.ktor.server.engine.EmbeddedServer.launchModuleByName(EmbeddedServerJvm.kt:348)
at io.ktor.server.engine.EmbeddedServer.access$launchModuleByName(EmbeddedServerJvm.kt:27)
at io.ktor.server.engine.EmbeddedServer$instantiateAndConfigureApplication$1.invoke(EmbeddedServerJvm.kt:336)
at io.ktor.server.engine.EmbeddedServer$instantiateAndConfigureApplication$1.invoke(EmbeddedServerJvm.kt:327)
at io.ktor.server.engine.EmbeddedServer.avoidingDoubleStartup(EmbeddedServerJvm.kt:355)
at io.ktor.server.engine.EmbeddedServer.instantiateAndConfigureApplication(EmbeddedServerJvm.kt:327)
at io.ktor.server.engine.EmbeddedServer.createApplication(EmbeddedServerJvm.kt:142)
at io.ktor.server.engine.EmbeddedServer.start(EmbeddedServerJvm.kt:270)
at com.example.ApplicationKt.main(Application.kt:10)
at com.example.ApplicationKt.main(Application.kt)
So, it happens when you try to use Simple-Cache for 2.3.11
with 3.0.0-beta-1
Ktor. There is no issue if update the library up to Ktor 3.0.0-beta-1
too.
However, I cannot find a good way for tests so far. But seems I will spend more time for it soon.
Thank you, this is because in version 2.3.11 Route is a class, but in 3.0.0-beta-1 it is an interface. I solved it temporarily by customizing the cacheOutput method.
How do you work around with this? I'm still experiencing this issue on 3.0.1
Hello @SinonCute ,
I started to revrite tests. Should finish on this week.
title :) I'd be willing to work on a PR if needed.