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
Prevent StackOverflowError in CompletableFuture.asDeferred and proper… #2731
Conversation
…ly report exceptions from completion handlers * It turned out that 'cancel' on completed future tries to help and invoke 'whenComplete' handlers that also invoke 'cancel' on the very same future * Use top-level exception handler as a last resort to deliver an exception Fixes #2730
class FutureAsDeferredUnhandledCompletionExceptionTest : TestBase() { | ||
|
||
// This is a separate test in order to avoid interference with uncaught exception handlers in other tests | ||
private val exceptionHandler = Thread.getDefaultUncaughtExceptionHandler() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: wouldn't it be more symmetrical if exceptionHandler
was also initialized in setUp
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it more concise to initialize in-place everything that could be initialized in-place, [opinionated] it reads better and is easier to reason about
integration/kotlinx-coroutines-guava/test/FutureAsDeferredUnhandledCompletionExceptionTest.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: dkhalanskyjb <52952525+dkhalanskyjb@users.noreply.github.com>
Kotlin#2731) Prevent StackOverflowError in CompletableFuture.asDeferred and properly report exceptions from completion handlers * It turned out that 'cancel' on completed future tries to help and invoke 'whenComplete' handlers that also invoke 'cancel' on the very same future * Use top-level exception handler as a last resort to deliver an exception Fixes Kotlin#2730
…ly report exceptions from completion handlers
Fixes #2730