Hi Stuart,
Here's the pattern:
```
public void handleRequest...{
if (exchange.isInIoThread())
{
exchange.dispatch(this);
return;
}
//do some I/O intensive work
//...
CompletableFuture.supplyAsync(.../*send email with logged exception handling*/...) //#A
exchange.getResponseSender().send(responseJson);
}
```
The line #A is inconsistent. The task in #A is executed by a thread in common forkjoin pool and may be that could be the reason? I'm not sure.
Maybe using one of undertow's worker threads might solve it? Is there a way to do so? All I want is to return response to the client immediately and execute delayable work in the background thread.
Thanks.