The issue is that in general when using that version of the method
there is no way to know if the call stack is still active when you
'come back to finish things'. This can result in two threads being
active in the exchange, which can result in hard to diagnose problems.
In general you should use:
dispatch(SameThreadExecutor.INSTANCE, () -> {startAsyncWork() });
Where whatever is in the Runnable is what kicks off your async work.
This means that the call stack will have returned before your async
work starts, so there is no chance of a race condition.
Stuart
On Fri, Sep 23, 2016 at 2:30 PM, Michael Hixson
<michael.hixson(a)gmail.com> wrote:
Hello,
I'm using the no-argument version of HttpServerExchange.dispatch(),
and I just noticed that it's deprecated.
I'm using dispatch() to suspend the exchange, to make sure the
exchange isn't completed when the call stack returns. Basically I'm
telling it, "Go to sleep. I'll be back later to finish things."
Is that an inappropriate use of dispatch()?
It's not clear that the suggested alternative of
dispatch(Executor,Runnable) is better in this case. What arguments
would I provide? dispatch(null, () -> {}) ?
-Michael
_______________________________________________
undertow-dev mailing list
undertow-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/undertow-dev