Skip to content

CoroutineScope.future() may trigger global exception handler on cancellation #3452

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
frost13it opened this issue Sep 13, 2022 · 1 comment
Closed
Labels

Comments

@frost13it
Copy link

Expected behavior

future coroutine builder delivers all errors via the returned object, just like async.

Actual behavior

future coroutine builder can suddenly trigger global exception handler that may crash the application.

Sample code:

fun main() {
    val future = GlobalScope.future {
        error("foo")
    }
    future.cancel(true)
    Thread.sleep(100)
}

Result:
Exception in thread "DefaultDispatcher-worker-1" java.lang.IllegalStateException: foo

@frost13it
Copy link
Author

I believe CompletableFutureCorotine should not attempt to handle the exception in any other way than completing the returned CompletableFuture. For now, this is not the case.

@qwwdfsad qwwdfsad added the bug label Sep 13, 2022
qwwdfsad added a commit that referenced this issue Jan 6, 2023
…builder if it has been cancelled in order to be consistent with other future implementations

Fixes #3452
qwwdfsad added a commit that referenced this issue Jan 6, 2023
…builder if it has been cancelled in order to be consistent with other future implementations

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

No branches or pull requests

2 participants