@@ -320,10 +320,10 @@ public open class JobSupport constructor(active: Boolean) : Job, ChildJob, Paren
320
320
}
321
321
322
322
/* *
323
- * The method that is invoked when the job is cancelled to possible propagate cancellation to the parent.
323
+ * The method that is invoked when the job is cancelled to possibly propagate cancellation to the parent.
324
324
* Returns `true` if the parent is responsible for handling the exception, `false` otherwise.
325
325
*
326
- * Invariant: never returns `true ` for instances of [CancellationException], otherwise such exception
326
+ * Invariant: never returns `false ` for instances of [CancellationException], otherwise such exception
327
327
* may leak to the [CoroutineExceptionHandler].
328
328
*/
329
329
private fun cancelParent (cause : Throwable ): Boolean {
@@ -619,19 +619,17 @@ public open class JobSupport constructor(active: Boolean) : Job, ChildJob, Paren
619
619
cancelImpl(parentJob)
620
620
}
621
621
622
- /* *
623
- * Returns `true` if job should cancel itself on child [CancellationException].
624
- */
625
- public open fun cancelOnChildCancellation (cause : CancellationException ) = false
626
-
627
622
/* *
628
623
* Child was cancelled with a cause.
629
- * In this method parent decides whether it cancels itself (e.g. on a critical failure) and
630
- * whether it handles the exception of the child.
624
+ * In this method parent decides whether it cancels itself (e.g. on a critical failure) and whether it handles the exception of the child.
631
625
* It is overridden in supervisor implementations to completely ignore any child cancellation.
626
+ * Returns `true` if exception is handled, `false` otherwise (then caller is responsible for handling an exception)
627
+ *
628
+ * Invariant: never returns `false` for instances of [CancellationException], otherwise such exception
629
+ * may leak to the [CoroutineExceptionHandler].
632
630
*/
633
631
public open fun childCancelled (cause : Throwable ): Boolean {
634
- if (cause is CancellationException && ! cancelOnChildCancellation(cause) ) return true
632
+ if (cause is CancellationException ) return true
635
633
return cancelImpl(cause) && handlesException
636
634
}
637
635
@@ -643,7 +641,7 @@ public open class JobSupport constructor(active: Boolean) : Job, ChildJob, Paren
643
641
644
642
// cause is Throwable or ParentJob when cancelChild was invoked
645
643
// returns true is exception was handled, false otherwise
646
- private fun cancelImpl (cause : Any? ): Boolean {
644
+ internal fun cancelImpl (cause : Any? ): Boolean {
647
645
if (onCancelComplete) {
648
646
// make sure it is completing, if cancelMakeCompleting returns true it means it had make it
649
647
// completing and had recorded exception
0 commit comments