From 92eb152fd61f381ae39e2887fcec4a564b06b058 Mon Sep 17 00:00:00 2001 From: vlad Date: Wed, 8 Nov 2017 04:18:44 -0800 Subject: App initialization convenience methods --- .../xyz/driver/core/logging/MdcExecutionContext.scala | 18 ++++++++++-------- 1 file 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() + } } }) } -- cgit v1.2.3