diff options
-rw-r--r-- | src/main/scala/xyz/driver/core/logging/MdcExecutionContext.scala | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/main/scala/xyz/driver/core/logging/MdcExecutionContext.scala b/src/main/scala/xyz/driver/core/logging/MdcExecutionContext.scala index f39f31d..df21b48 100644 --- a/src/main/scala/xyz/driver/core/logging/MdcExecutionContext.scala +++ b/src/main/scala/xyz/driver/core/logging/MdcExecutionContext.scala @@ -13,14 +13,16 @@ import scala.concurrent.ExecutionContext class MdcExecutionContext(executionContext: ExecutionContext) extends ExecutionContext { override def execute(runnable: Runnable): Unit = { val callerMdc = MDC.getCopyOfContextMap - executionContext.execute(() => { - // copy caller thread diagnostic context to execution thread - Option(callerMdc).foreach(MDC.setContextMap) - try { - runnable.run() - } finally { - // the thread might be reused, so we clean up for the next use - MDC.clear() + executionContext.execute(new Runnable { + def run(): Unit = { + // copy caller thread diagnostic context to execution thread + Option(callerMdc).foreach(MDC.setContextMap) + try { + runnable.run() + } finally { + // the thread might be reused, so we clean up for the next use + MDC.clear() + } } }) } |