Klitos Kyriacou
04/09/2024, 8:34 AMMDC.put(some context...)
withContext(<http://Dispatchers.IO|Dispatchers.IO> + MDCContext()) {
...some asynchronous processing...
}
// At this point MDC is clear, the original context has disappeared!
After the withContext
call, the entries in the MDC have all been removed and the context map is empty. Does anyone have any clues how I can go about figuring out how/why/where this context is getting zapped?Sam
04/09/2024, 8:46 AMwithContext
changes dispatchers, there's no guarantee that line 5 is running on the same thread as line 1. You'd need the MDCContext
installed higher up if you want to rely on its contents outside the withContext
block.Klitos Kyriacou
04/09/2024, 8:52 AMKlitos Kyriacou
04/09/2024, 9:31 AMwithContext
call, it seems to be the same thread (at least same ID) on lines 1 and 5. Is there any other way the context can disappear? (I'll change this anyway, to make sure the context is saved higher up.)Sam
04/09/2024, 9:53 AMMDCContext
is already installed in the context higher up? Since withContext
is a suspension point, it would trigger the MDCContext
to restore its original saved state when withContext
returns.Sam
04/09/2024, 9:54 AMdelay()
.Klitos Kyriacou
04/09/2024, 9:56 AMSam
04/09/2024, 9:58 AM