Skip to content

Commit c9b097e

Browse files
committed
Mention exceptions in ThreadContextElement (see Kotlin#773)
1 parent 77d1aea commit c9b097e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/kotlinx-coroutines-core/src/ThreadContextElement.kt

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public interface ThreadContextElement<S> : CoroutineContext.Element {
5555
* This function is invoked before the coroutine in the specified [context] is resumed in the current thread
5656
* when the context of the coroutine this element.
5757
* The result of this function is the old value of the thread-local state that will be passed to [restoreThreadContext].
58+
* This method should handle its own exceptions and do not rethrow it. Thrown exceptions will leave coroutine which
59+
* context is updated in an undefined state.
5860
*
5961
* @param context the coroutine context.
6062
*/
@@ -66,6 +68,8 @@ public interface ThreadContextElement<S> : CoroutineContext.Element {
6668
* if [updateThreadContext] was previously invoked on resume of this coroutine.
6769
* The value of [oldState] is the result of the previous invocation of [updateThreadContext] and it should
6870
* be restored in the thread-local state by this function.
71+
* This method should handle its own exceptions and do not rethrow it. Thrown exceptions will leave coroutine which
72+
* context is updated in an undefined state.
6973
*
7074
* @param context the coroutine context.
7175
* @param oldState the value returned by the previous invocation of [updateThreadContext].

0 commit comments

Comments
 (0)