apache / logging-log4j-kotlin

A Kotlin-friendly interface to log against the Log4j API
https://logging.apache.org/log4j/kotlin
Apache License 2.0
45 stars 11 forks source link

Coroutine context is not cleared properly #54

Closed rocketraman closed 7 months ago

rocketraman commented 7 months ago

The coroutine context is not cleared properly. This test fails:

  @Test
  fun `Context is restored after a context block is complete`() = runBlocking {
    assertTrue(ContextMap.empty)
    assertTrue(ContextStack.empty)
    withContext(CoroutineThreadContext(ThreadContextData(mapOf("myKey" to "myValue"), listOf("test")))) {
      assertEquals("myValue", ContextMap["myKey"])
      assertEquals("test", ContextStack.peek())
    }
    assertTrue(ContextMap.empty)
    assertTrue(ContextStack.empty)
  }