Skip to content

Commit 428d987

Browse files
committed
Avoid extra creation of CancellationException to notify completion listeners
1 parent 7886ef6 commit 428d987

File tree

1 file changed

+2
-2
lines changed
  • kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental

1 file changed

+2
-2
lines changed

kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/Job.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public open class JobSupport(active: Boolean) : AbstractCoroutineContextElement(
322322

323323
internal fun completeUpdateState(expect: Any, update: Any?) {
324324
// Invoke completion handlers
325-
val cause = (update as? CompletedExceptionally)?.exception
325+
val cause = (update as? CompletedExceptionally)?.cause
326326
var completionException: Throwable? = null
327327
when (expect) {
328328
// SINGLE/SINGLE+ state -- one completion handler (common case)
@@ -537,7 +537,7 @@ public open class JobSupport(active: Boolean) : AbstractCoroutineContextElement(
537537
* @param cause the exceptional completion cause. If `cause` is null, then a [CancellationException]
538538
* if created on first get from [exception] property.
539539
*/
540-
public open class CompletedExceptionally(cause: Throwable?) {
540+
public open class CompletedExceptionally(val cause: Throwable?) {
541541
@Volatile
542542
private var _exception: Throwable? = cause // materialize CancellationException on first need
543543

0 commit comments

Comments
 (0)