The following test passes with version `2.1.23`and...
# kotlin-logging
e
The following test passes with version `2.1.23`and fails with version `3.0.4`:
Copy code
import kotlinx.coroutines.runBlocking
import mu.KotlinLogging
import org.junit.jupiter.api.Test

internal class MdcTest {
    @Test
    fun testMdcContextBehavior() = runBlocking {
        withContext(MDCContext(mapOf("foo" to "bar"))) {
            logger.warn { "context should have bar" }
            assertEquals(MDC.get("foo"}), "bar")

            awaitAll(
                async { assertMdcContext("bar1") },
                async { assertMdcContext("bar2") }
            )

            logger.warn { "context should have bar " }
            assertEquals(MDC.get("foo"), "bar")
        }
    }

    private suspend fun assertMdcContext(id: String) {
        withContext(MDCContext(mapOf("foo" to id))) {
            logger.warn { "message with $id" }
            assertEquals(MDC.get("foo"), id)
        }
    }
}
the failure happens because the underlying mdc adapter is
NOPMDCAdapter
o
Would you like to open an issue for it?
e
o
Thanks! Will take a look. Will also try to test it with the new V4 beta