I have a classA which is running on Tomcat thread. ClassA is maintaining a set of MDC key-values pairs.
As the ClassA is executed, MDC.getCopyOfContextMap()
returns (A="a", B="b", C="c")
Now, ClassA calls classB which is running on Hystrix thread.
When we enter ClassB, MDC from ClassA is copied and MDC.getCopyOfContextMap()
returns (A="a", B="b", C="c").
ClassB sets a value of a variable X into MDC.
MDC.put("X", String.valueOf("someVal"))
When still inside ClassB, MDC.getCopyOfContextMap()
returns (A="a", B="b", C="c", X="someVal").
ClassA receives the MDC and tries to access the variable X.
MDC.get(X)
But it gets it as null becauseMDC.getCopyOfContextMap()
returns (A="a", B="b", C="c").
Any suggestions why MDC is not transferred from Hystrix thread to tomcat thread?