Skip to content
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

[guava] JobListenableFuture.isCancelled() throws if future is completed exceptionally #2421

Closed
vadimsemenov opened this issue Dec 1, 2020 · 0 comments

Comments

@vadimsemenov
Copy link
Contributor

The bug was introduced in #2222

    @Test
    fun testFailedFuture_isCancelledDoesNotThrow() = runTest {
        val future = future(context = NonCancellable) {
            throw TestException()
        }
        yield()
        assertTrue(future.isDone)
        assertFalse(future.isCancelled)  // throws ExecutionException here.
        val thrown = assertFailsWith<ExecutionException> { future.get() }
        assertTrue(thrown.cause is TestException)
    }

Uninteraptables.getUninterruptibly(future) throws ExecutionException if the future is completed exceptionally.

vadimsemenov added a commit to vadimsemenov/kotlinx.coroutines that referenced this issue Dec 1, 2020
This properly handles ExecutionException that can be thrown from getUninterruptibly.

Fixed Kotlin#2421.
vadimsemenov added a commit to vadimsemenov/kotlinx.coroutines that referenced this issue Jan 26, 2021
This properly handles ExecutionException that can be thrown from getUninterruptibly.

Fixed Kotlin#2421.
qwwdfsad pushed a commit that referenced this issue Jan 27, 2021
This properly handles ExecutionException that can be thrown from getUninterruptibly.

Fixed #2421.
qwwdfsad added a commit that referenced this issue Jan 27, 2021
* Fix toString representation of JobListenableFuture
* Do not throw from JobListenableFuture.isCancelled. This properly handles ExecutionException that can be thrown from getUninterruptibly.

Co-authored-by: Vadim Semenov <vadim.pillarbox@gmail.com>

Fixes #2421
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

1 participant