i have web application. application deployed tomcat. write servlet filter put data in mdc class @ slf4j following code:
mdc.put("id", uuid.randomuuid().tostring();
when run application second or third request duplicate uuid. scenario serial , isn't concurrent. think there exists thread pool thread context don't clear.
use structure guarantee id removed:
try { mdc.put("id", uuid.randomuuid().tostring()); // rest of code } { mdc.remove("id"); } (no catch block necessary). guarantee id key removed transaction.
also, of course tomcat uses thread pool, how manages requests when concurrent. further reading: https://tomcat.apache.org/tomcat-6.0-doc/config/executor.html
Comments
Post a Comment