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

Fill in stacktrace of cancellation exception with an empty array to p… #1868

Merged
merged 1 commit into from Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion kotlinx-coroutines-core/jvm/src/Exceptions.kt
Expand Up @@ -40,7 +40,8 @@ internal actual class JobCancellationException public actual constructor(
if (DEBUG) {
return super.fillInStackTrace()
}

// Prevent Android <= 6.0 bug, #1866
stackTrace = emptyArray()
/*
* In non-debug mode we don't want to have a stacktrace on every cancellation/close,
* parent job reference is enough. Stacktrace of JCE is not needed most of the time (e.g., it is not logged)
Expand Down
Expand Up @@ -12,14 +12,18 @@ internal actual class AbortFlowException actual constructor(
) : CancellationException("Flow was aborted, no more elements needed") {

override fun fillInStackTrace(): Throwable {
if (DEBUG) super.fillInStackTrace()
if (DEBUG) return super.fillInStackTrace()
// Prevent Android <= 6.0 bug, #1866
stackTrace = emptyArray()
return this
}
}

internal actual class ChildCancelledException : CancellationException("Child of the scoped flow was cancelled") {
override fun fillInStackTrace(): Throwable {
if (DEBUG) super.fillInStackTrace()
if (DEBUG) return super.fillInStackTrace()
// Prevent Android <= 6.0 bug, #1866
stackTrace = emptyArray()
return this
}
}