kotlinx.coroutines icon indicating copy to clipboard operation
kotlinx.coroutines copied to clipboard

Substantial mistake in documentation of Supervision

Open DorBSoft opened this issue 1 year ago • 0 comments
trafficstars

/docs/topics/exception-handling.md

The "Supervision" section appears to be wrong throughout its text by using the term "cancellation" instead of the term "failure". I.e. the text is suggesting it is about "cancel()", while it is actually about throwing any exception but "CancellationException".

"cancellation is a bidirectional relationship propagating through the whole hierarchy of coroutines.". Wrong. "Failure is a bidirectional relationship...". "cancel()" is one-directional.

"It is similar to a regular Job with the only exception that cancellation is propagated only downwards." Wrong.

If there is a need, the fact that cancel() is not bidirectional can be easily seen by doing the following changed in the example code:

val supervisor = coroutineContext//SupervisorJob() ... cancel/throw AssertionError/("The first child is cancelled") ... secondChild.join()//order replaced supervisor.cancel()

DorBSoft avatar Dec 29 '23 14:12 DorBSoft