Thank you for your answers. I understand I need to explicitly set MDC in worker thread. Problem is I cannot modify the codebase of application that runs on Wildfly. Actually it is a war deployed into Wildfly, and I cannot re-build it. I want to customize only undertow/wildfly.
The custom handler I add this way runs in IO thread:
/subsystem=undertow/configuration=filter/custom-filter=correlation:add(module="com.ingrammicro.idp.undertow-correlation",class-name=com.ingrammicro.idp.CorrelationHandler)
/subsystem=undertow/server=default-server/host=default-host/filter-ref=correlation:add()
But from stacktrace I see multiple handlers run in worker thread:
handleRequest:43, PredicateHandler (io.undertow.server.handlers)
handleRequest:68, RedirectDirHandler (io.undertow.servlet.handlers)
handleRequest:132, SSLInformationAssociationHandler (io.undertow.servlet.handlers.security)
handleRequest:57, ServletAuthenticationCallHandler (io.undertow.servlet.handlers.security)
Also, I can add an expression handler that runs in worker thread:
/subsystem=undertow/configuration=filter/expression-filter=IM_private:add(,expression="path-template('/auth/realms/{realm}/restart-session') -> ip-access-control(acl={'127.0.0.1 allow', '0:0:0:0:0:0:0:1 allow'})")
/subsystem=undertow/server=default-server/host=default-host/filter-ref=IM_private:add()
Is it possible to add a custom handler to run in a worker thread?