-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java.lang.ClassCastException: to CoroutineStackFrame
at kotlinx.coroutines.internal.ScopeCoroutine.getCallerFrame(Scopes.kt:19)
#2386
Comments
Thanks for the report! Filed https://youtrack.jetbrains.com/issue/KT-43395 This is indeed bug on our side worth fixing, but while we are here, I would strongly suggest implementing
This change will improve debugging experience of Micronaut+coroutines usage, including IDE debugging and runtime exceptions recovery machinery |
@qwwdfsad thanks for the feedback! As far as we could tell, |
While it may seem dangerous to implement it because it is internal, we are not going to change it because a lot of binary code already depend on it. The worst thing we can do is to "deprecate it" with a replacement to the same very interface but in another package |
@qwwdfsad alright then, sounds like something to PR against micronaut :) thanks for the clarification! |
For library authors wishing to implement a custom
kotlin.coroutines.Continuation
class, casting to an internal class likeCoroutineStackFrame
is problematic.See, for example, this issue filed against micronaut:
micronaut-projects/micronaut-core#4438
The error comes on this line, where micronaut has implemented
Continuation
with theCompletableFutureContinuation
classhttps://github.com/micronaut-projects/micronaut-core/blob/0afdef29d0a6b38b55dc39e3ef2a72bea85be45f/aop/src/main/java/io/micronaut/aop/internal/intercepted/KotlinInterceptedMethod.java#L123
I think the solve is to have
ScopeCoroutine
optionally castuCont
toCoroutineStackFrame
, ascallerFrame
is nullable anyway (and it also seems like what other implementations ofCoroutineStackFrame
, likeSelectBuilderImpl
andStackFrameContinuation
are doing).I can work on adding a test to reproduce this issue and create a PR since I'm already in the weeds on it, will update once I do!
The text was updated successfully, but these errors were encountered: