<div dir="ltr">unfortunately, there is no Local.java at this point BUT hopefully this stackoverflow question explains how MDC is broken across CompletableFuture but works fine for twitter Future<div><br></div><div><a href="https://stackoverflow.com/questions/37933713/does-completablefuture-have-a-corresponding-local-context">https://stackoverflow.com/questions/37933713/does-completablefuture-have-a-corresponding-local-context</a><br></div><div><br></div><div>NOTE: We swap the MDC with one depending on Local.scala instead of ThreadLocal(threadlocal breaks since many threads execute 1 request when using Future or CompletableFuture).</div><div><br></div><div>thanks,</div><div>Dean</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 22, 2018 at 8:18 AM, Ceki <span dir="ltr"><<a href="mailto:ceki@qos.ch" target="_blank">ceki@qos.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
Hello Dean,<br>
<br>
What is Local.java ? Do you mean thread local? Please show an example of what you would like to happen.<br>
<br>
Best regards,<br>
--<br>
Ceki<div><div class="h5"><br>
<br>
<br>
On <a href="tel:22.03.2018%2014" value="+12203201814" target="_blank">22.03.2018 14</a>:51, Dean Hiller wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Has anyone requested the jdk to add Local.java to CompletableFuture.java so that context can be transferred through the .thenApply and .thenCompose methods.  ie. can we make MDC work in java-land with CompletableFutures?  (it works in scala land with twitter scala Future by swapping the MDC out for the below thing I describe)<br>
<br>
let me go into more detail here.  We use twitter Future.scala which knows about Local.scala and Local.scala "acts" like a ThreadLocal.  I say acts because when you do future.map/flatMap(in java that is thenApply/thenCompose), it transfers the threadlocal through to the next executing function.<br>
<br>
soooo, long story short, in twitter servers, I can say MDC.put("requestId", someRequestId) and it works over the .map/.flatMap.  This is not possible in java!!!!! ahhhhh....<br>
<br>
and I wrote a whole webserver in java with CompletableFutures before I found this out <a href="https://github.com/deanhiller/webpieces" rel="noreferrer" target="_blank">https://github.com/deanhiller/<wbr>webpieces</a><br>
<br>
ps. their response was that it would be a global.  Sure, but I am practical and it solves a huge many platform problems like MDC, and some in my server where I don't know the customers code(and I had to hack around not having a Local type thing available :( ).<br>
<br>
Another reason they elude to is some methods they don't know how to handle Local in those cases(yup, well scala had the same thing but it managed to implement it because it was too important and now java is behind :( ).<br>
<br>
Anyways, it would be nice if others spoke up before they realize they need it for the MDC to keep working.<br>
<br>
thanks,<br>
Dean<br>
<br>
<br>
<br></div></div>
______________________________<wbr>_________________<br>
slf4j-dev mailing list<br>
<a href="mailto:slf4j-dev@qos.ch" target="_blank">slf4j-dev@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/slf4j-dev" rel="noreferrer" target="_blank">http://mailman.qos.ch/mailman/<wbr>listinfo/slf4j-dev</a><br>
<br><span class="HOEnZb"><font color="#888888">
</font></span></blockquote><span class="HOEnZb"><font color="#888888">
<br>
-- <br>
--<br>
Ceki Gülcü<br>
______________________________<wbr>_________________<br>
slf4j-dev mailing list<br>
<a href="mailto:slf4j-dev@qos.ch" target="_blank">slf4j-dev@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/slf4j-dev" rel="noreferrer" target="_blank">http://mailman.qos.ch/mailman/<wbr>listinfo/slf4j-dev</a></font></span></blockquote></div><br></div>