[slf4j-dev] MDC works with twitter scala Future but not CompletableFuture

Ceki ceki at qos.ch
Thu Mar 22 15:18:51 CET 2018



Hello Dean,

What is Local.java ? Do you mean thread local? Please show an example of 
what you would like to happen.

Best regards,
--
Ceki


On 22.03.2018 14:51, Dean Hiller wrote:
> 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)
> 
> 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.
> 
> 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....
> 
> and I wrote a whole webserver in java with CompletableFutures before I 
> found this out https://github.com/deanhiller/webpieces
> 
> 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 :( ).
> 
> 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 :( ).
> 
> Anyways, it would be nice if others spoke up before they realize they 
> need it for the MDC to keep working.
> 
> thanks,
> Dean
> 
> 
> 
> _______________________________________________
> slf4j-dev mailing list
> slf4j-dev at qos.ch
> http://mailman.qos.ch/mailman/listinfo/slf4j-dev
> 

-- 
--
Ceki Gülcü


More information about the slf4j-dev mailing list