Skip to content

JobSupport.kt: fix GH!3658 #3817

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
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions kotlinx-coroutines-core/common/src/JobSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ public open class JobSupport constructor(active: Boolean) : Job, ChildJob, Paren
* This allow parent to cancel its children (normally) without being cancelled itself, unless
* child crashes and produce some other exception during its completion.
*/
val isCancellation = cause is CancellationException
val isCancellation = cause is JobCancellationException &&
(cause.job as JobSupport).state.let{it is Finishing && it.isCancelling()}
val parent = parentHandle
// No parent -- ignore CE, report other exceptions.
if (parent === null || parent === NonDisposableHandle) {
Expand Down Expand Up @@ -651,7 +652,9 @@ public open class JobSupport constructor(active: Boolean) : Job, ChildJob, Paren
* may leak to the [CoroutineExceptionHandler].
*/
public open fun childCancelled(cause: Throwable): Boolean {
if (cause is CancellationException) return true
if(cause is JobCancellationException &&
(cause.job as JobSupport).state.let{it is Finishing && it.isCancelling()})
return true
return cancelImpl(cause) && handlesException
}

Expand Down