Search code examples
wildflyundertow

Undertow's ThreadSetupAction: null exchange


I'm using Wildfly 8.1.0.Final, which has Undertow 1.0.15.Final bundled.
I have a certain ThreadSetupAction implementation, that gets called with a null exchange sporadically. I'm not sure how to correctly handle this case.

ThreadSetupAction's javadoc says:

Interface that can be implemented by classes that need to setup and thread local context before a request is processed.

ThreadSetupAction#setup's javadoc mentions:

Parameters:
exchange The exchange, this may be null

So what does it mean, when the exchange is null? How can there be a request without an exchange?
So far I was unable to catch this with a debugger.


Solution

  • ThreadSetupAction#setup gets called with a null exchange in the following cases.

    • Deployment events: deploy, undeploy, start, stop.
    • Servlets' AsyncContext.start.
    • Servlets' sessionDestroyed event.