Skip to content

Commit bb22ae6

Browse files
committed
Duct-tape fix for #2930
1 parent 90fa892 commit bb22ae6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kotlinx-coroutines-core/jvm/src/CoroutineContext.kt

+8
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@ internal actual class UndispatchedCoroutine<in T>actual constructor (
181181
*/
182182
private var threadStateToRecover = ThreadLocal<Pair<CoroutineContext, Any?>>()
183183

184+
init {
185+
// TODO explain this
186+
if (uCont.context[ContinuationInterceptor] !is CoroutineDispatcher) {
187+
val values = updateThreadContext(context, null)
188+
threadStateToRecover.set(context to values)
189+
}
190+
}
191+
184192
fun saveThreadContext(context: CoroutineContext, oldValue: Any?) {
185193
threadStateToRecover.set(context to oldValue)
186194
}

0 commit comments

Comments
 (0)