calling a ktor client with runBlocking(Dispatchers...
# coroutines
b
calling a ktor client with runBlocking(Dispatchers.Default) { ... } the request fails due to the wrong method type (requires POST instead of GET), but I'm getting an exception that is different than I'd expect:
Copy code
kotlinx.coroutines.CompletionHandlerException: Exception in completion handler InvokeOnCompletion@7429f803[job@17390f1] for SupervisorJobImpl{Cancelled}@17390f1
	at kotlinx.coroutines.JobSupport.notifyCompletion(JobSupport.kt:1629) ~[kotlinx-coroutines-core-jvm-1.10.2.jar:na]
	at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:316) ~[kotlinx-coroutines-core-jvm-1.10.2.jar:na]
	at kotlinx.coroutines.JobSupport.finalizeFinishingState(JobSupport.kt:233) ~[kotlinx-coroutines-core-jvm-1.10.2.jar:na]
	at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:946) ~[kotlinx-coroutines-core-jvm-1.10.2.jar:na]
	at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:894) ~[kotlinx-coroutines-core-jvm-1.10.2.jar:na]
	at kotlinx.coroutines.JobSupport.makeCompleting$kotlinx_coroutines_core(JobSupport.kt:837) ~[kotlinx-coroutines-core-jvm-1.10.2.jar:na]
	at kotlinx.coroutines.JobImpl.completeExceptionally(JobSupport.kt:1441) ~[kotlinx-coroutines-core-jvm-1.10.2.jar:na]
	at io.ktor.client.plugins.HttpRequestLifecycleKt$HttpRequestLifecycle$1$1.invokeSuspend(HttpRequestLifecycle.kt:31) ~[ktor-client-core-jvm-3.5.2.jar:3.5.2]
	at io.ktor.client.plugins.HttpRequestLifecycleKt$HttpRequestLifecycle$1$1.invoke(HttpRequestLifecycle.kt) ~[ktor-client-core-jvm-3.5.2.jar:3.5.2]
	at io.ktor.client.plugins.HttpRequestLifecycleKt$HttpRequestLifecycle$1$1.invoke(HttpRequestLifecycle.kt) ~[ktor-client-core-jvm-3.5.2.jar:3.5.2]
	at io.ktor.client.plugins.SetupRequestContext$install$1.invokeSuspend(HttpRequestLifecycle.kt:42) ~[ktor-client-core-jvm-3.5.2.jar:3.5.2]
	at io.ktor.client.plugins.SetupRequestContext$install$1.invoke(HttpRequestLifecycle.kt) ~[ktor-client-core-jvm-3.5.2.jar:3.5.2]
	at io.ktor.client.plugins.SetupRequestContext$install$1.invoke(HttpRequestLifecycle.kt) ~[ktor-client-core-jvm-3.5.2.jar:3.5.2]
	at io.ktor.util.pipeline.DebugPipelineContext.proceedLoop(DebugPipelineContext.kt:79) ~[ktor-utils-jvm-3.5.2.jar:3.5.2]
	at io.ktor.util.pipeline.DebugPipelineContext.proceed(DebugPipelineContext.kt:57) ~[ktor-utils-jvm-3.5.2.jar:3.5.2]
	at io.ktor.util.pipeline.DebugPipelineContext.execute$ktor_utils(DebugPipelineContext.kt:63) ~[ktor-utils-jvm-3.5.2.jar:3.5.2]
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:92) ~[ktor-utils-jvm-3.5.2.jar:3.5.2]
	at io.ktor.client.HttpClient.execute$ktor_client_core(HttpClient.kt:1420) ~[ktor-client-core-jvm-3.5.2.jar:3.5.2]
	at io.ktor.client.statement.HttpStatement.fetchResponse(HttpStatement.kt:207) ~[ktor-client-core-jvm-3.5.2.jar:3.5.2]
	at io.ktor.client.statement.HttpStatement.execute(HttpStatement.kt:100) ~[ktor-client-core-jvm-3.5.2.jar:3.5.2]
	at at.fyayc.emporixapi.auth.AnonymousOAuthClient.login(AnonymousOAuthClient.kt:65) ~[main/:na]
	at at.fyayc.backend.emporixapi.SessionTokenStorage$load$1.invokeSuspend(SessionTokenStorage.kt:32) ~[main/:na]
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith$$$capture(ContinuationImpl.kt:34) ~[kotlin-stdlib-2.4.10.jar:2.4.10-release-377]
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt) ~[kotlin-stdlib-2.4.10.jar:2.4.10-release-377]
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100) ~[kotlinx-coroutines-core-jvm-1.10.2.jar:na]
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586) ~[kotlinx-coroutines-core-jvm-1.10.2.jar:na]
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:829) ~[kotlinx-coroutines-core-jvm-1.10.2.jar:na]
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717) ~[kotlinx-coroutines-core-jvm-1.10.2.jar:na]
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704) ~[kotlinx-coroutines-core-jvm-1.10.2.jar:na]
Caused by: java.lang.NoSuchMethodError: 'void kotlinx.coroutines.Job.cancel$default(kotlinx.coroutines.Job, java.util.concurrent.CancellationException, int, java.lang.Object)'
	at io.ktor.client.plugins.HttpTimeoutKt.applyRequestTimeout$lambda$0(HttpTimeout.kt:192) ~[ktor-client-core-jvm-3.5.2.jar:3.5.2]
	at kotlinx.coroutines.InvokeOnCompletion.invoke(JobSupport.kt:1534) ~[kotlinx-coroutines-core-jvm-1.10.2.jar:na]
	at kotlinx.coroutines.JobSupport.notifyCompletion(JobSupport.kt:1625) ~[kotlinx-coroutines-core-jvm-1.10.2.jar:na]
	... 28 common frames omitted
What am I doing wrong?
✅ 1
🧵 3
e
library versions?
b
is this classpath hell?
e
almost certainly
b
I see coroutines 1.11.0 and 1.10.2 being pulled in by different kotlin libs
ktor logging for instance pulls in 1.10.2
e
then you should only have 1.11.0 in your classpath
both is a disaster waiting to happen (like this)
b
that's what I want, right \--- org.jetbrains.kotlinkotlin compiler runner2.4.10 +--- org.jetbrains.kotlinkotlin daemon client2.4.10 \--- org.jetbrains.kotlinxkotlinx coroutines core jvm1.8.0 -> 1.11.0 (*)
and I suppose this is the issue
Copy code
migrationTestCompileClasspath - Compile classpath for 'migrationTest'.
+--- org.jetbrains.kotlin:kotlin-stdlib:2.4.10
|    \--- org.jetbrains:annotations:13.0 -> 23.0.0
+--- at.fyayc:emporix-api-client -> project ':api-client'
|    +--- io.ktor:ktor-serialization-kotlinx-json:3.5.2
|    |    \--- io.ktor:ktor-serialization-kotlinx-json-jvm:3.5.2
|    |         +--- org.slf4j:slf4j-api:2.0.18
|    |         +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.11.0
|    |         |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 -> 1.10.2
|    |         |         +--- org.jetbrains:annotations:23.0.0
e
that's Gradle doing the right thing by default, yes. latest of all requested versions
b
Copy code
1.11.0 -> 1.10.2
even that one?
e
oh that's not
1.8.0 -> 1.11.0 is 👍
1.11.0 -> 1.10.2 is 👎
b
I fear it might be the spring boot dependency plugin forcing this in
yep, that was it
had to downgrade coroutines and ktor client