aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlad <vlad@driver.xyz>2017-11-08 04:18:44 -0800
committervlad <vlad@driver.xyz>2017-11-08 04:18:44 -0800
commit92eb152fd61f381ae39e2887fcec4a564b06b058 (patch)
tree6f1302885a76dc60a94d2125b1897ce87740c148
parent56f7aa3b6a45d4309cc2c77fcac7e6fda5f45e55 (diff)
downloaddriver-core-92eb152fd61f381ae39e2887fcec4a564b06b058.tar.gz
driver-core-92eb152fd61f381ae39e2887fcec4a564b06b058.tar.bz2
driver-core-92eb152fd61f381ae39e2887fcec4a564b06b058.zip
App initialization convenience methods
-rw-r--r--src/main/scala/xyz/driver/core/logging/MdcExecutionContext.scala18
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()
+ }
}
})
}