Skip to content

Using CoroutineName as coroutine context leads to "java.lang.IllegalArgumentException: Must be used with DispatchedContinuation" on coroutine resume #133

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

Closed
wild-lynx opened this issue Sep 22, 2017 · 2 comments

Comments

@wild-lynx
Copy link

Run the following code:

fun main(args: Array<String>) = runBlocking(CoroutineName("channels.main")) {
    val c = async(CoroutineName("c coroutine")) {
        delay(500) // exception will be thrown while resuming
        42
    }
    val res = c.await()
}

You will get an exception:

Exception in thread "kotlinx.coroutines.DefaultExecutor" java.lang.IllegalArgumentException: Must be used with DispatchedContinuation
at kotlinx.coroutines.experimental.CancellableContinuationImpl.resumeUndispatched(CancellableContinuation.kt:252)
at kotlinx.coroutines.experimental.EventLoopBase$DelayedResumeTask.run(EventLoop.kt:237)
at kotlinx.coroutines.experimental.EventLoopBase.processNextEvent(EventLoop.kt:129)
at kotlinx.coroutines.experimental.DefaultExecutor.run(DefaultExecutor.kt:54)
at java.lang.Thread.run(Thread.java:748)

The example is taken and reduced from here

1.1.50-master-dev + IDEA 2017.2.5 RC IU-172.4343.5
1.2-Beta-eap-21 + IDEA 2017.2.5 RC IU-172.4343.5 | IDEA 2017.3 EAP IC-173.2463.16

elizarov added a commit that referenced this issue Sep 28, 2017
@elizarov
Copy link
Contributor

Fixed in develop branch

@elizarov
Copy link
Contributor

Released in version 0.19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants