The wildfly-http-client library is used to allow EJB client applications to invoke EJB client-related operations using the HTTP protocol. These EJB client invocations may be invoked while in transaction scope, and the invocation thread uses various thread-local Contextuals to manage the transactions, such as LocalTransactionContext, RemoteTransactionContext and ContextTransactionManager.
The wildfly-http-client library makes use of an HttpTargetContext to send the invocation from client to server and the HttpTargetContext in turn delegates to an HttpConnectionPool to establish the connection, setup the invocation request and send the invocation along this connection. Rather than performing the sending of the request using the calling thread, the HttpConnectionPool method getConnection() will add a connection request to a queue and then call runPending() to run any pending requests held in the queue. The connection for processing the pending request is obtained via UndertowClient.getInstance().connect(lambda expression involving connection, ...) and once obtained, the lambda expression is called. This lambda performs all of the request setup processing, including checking for transactions and marshalling any transaction state into the payload of the request.
At present, the thread used to call UndertowClient.getInstance().connect() and the thread used to call the lambda expression are not the same, and the Contextuals associated with the calling thread have been dropped before they can be used to process the request.
This mechanism needs to be fixed so that if thread transfers do occur, the contexts are carried over from the old thread to the new thread.