Does CompletableFuture have a corresponding Local context?

泄露秘密 提交于 2019-12-03 07:47:35

If you come across this, just poke the thread here http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-May/047867.html

to implement something like twitter Futures which transfer Locals (Much like ThreadLocal but transfers state).

See the def respond() method in here and how it calls Locals.save() and Locals.restort() https://github.com/simonratner/twitter-util/blob/master/util-core/src/main/scala/com/twitter/util/Future.scala

If Java Authors would fix this, then the MDC in logback would work across all 3rd party libraries. Until then, IT WILL NOT WORK unless you can change the 3rd party library(doubtful you can do that).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!