<div dir="ltr">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)<div><br></div><div>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.</div><div><br></div><div>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....</div><div><br></div><div>and I wrote a whole webserver in java with CompletableFutures before I found this out <a href="https://github.com/deanhiller/webpieces">https://github.com/deanhiller/webpieces</a></div><div><br></div><div>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 :( ).</div><div><br></div><div>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 :( ).</div><div><br></div><div>Anyways, it would be nice if others spoke up before they realize they need it for the MDC to keep working.</div><div><br></div><div>thanks,</div><div>Dean</div><div><br></div></div>