<div dir="ltr">and FYI, this was the list it was discussed on (MDC only works in futures in scala not CompletableFutuers in java unless they fix CompletableFuture)...(but perhaps I am not explaining it all correctly)...<div><br></div><div><table cellpadding="0" class="gmail-ajC" style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><tbody><tr class="gmail-ajv"><td colspan="2" class="gmail-gL" style="font-family:arial,sans-serif;margin:0px;white-space:normal;vertical-align:top;width:auto;padding:6px 0px"><span class="gmail-gI" style="vertical-align:top"><span><br class="gmail-Apple-interchange-newline">Martin Buchholz <<a href="mailto:martinrb@google.com">martinrb@google.com</a>></span>,<br><span>Pavel Rappo <<a href="mailto:pavel.rappo@oracle.com">pavel.rappo@oracle.com</a>></span>,<br><span>concurrency-interest <<a href="mailto:concurrency-interest@cs.oswego.edu">concurrency-interest@cs.oswego.edu</a>></span>,<br><span>core-libs-dev <<a href="mailto:core-libs-dev@openjdk.java.net">core-libs-dev@openjdk.java.net</a>></span></span></td></tr></tbody></table><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 22, 2018 at 8:38 AM, Dean Hiller <span dir="ltr"><<a href="mailto:dhiller@twitter.com" target="_blank">dhiller@twitter.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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" target="_blank">https://stackoverflow.com/<wbr>questions/37933713/does-<wbr>completablefuture-have-a-<wbr>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="HOEnZb"><div class="h5"><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="m_6603580000710953524h5"><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="m_6603580000710953524h5">
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="m_6603580000710953524HOEnZb"><font color="#888888">
</font></span></blockquote><span class="m_6603580000710953524HOEnZb"><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>
</div></div></blockquote></div><br></div>