On Tue, Mar 20, 2018 at 12:23 AM, Mario Carbajal <mario.e.carbajal(a)gmail.com
wrote:
In a dispatched non-blocking HttpRequest handler I'm calling
endExchange
immediately after calling send on the response Sender. I am unsure if this
will cause the sender to be interrupted or if the exchange will end only
after the sender is done writing the data.
Don't do that. It will appear to work for short responses where the data
can be written out in a single write() call, but if it needs to be written
out by the IO thread the data will be truncated.
Once the send is completed the sender will call endExchange for you, there
is no need to do it yourself (assuming you are using the version that does
not take a completion callback, the default callback just calls
endExchange. If you are using a callback you will need to end it yourself).
Stuart
The code looks like this:
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception
{
if (exchange.isInIoThread()) {
exchange.dispatch(this);
return;
}
try {
... do things ...
exchange.getResponseSender().send(data);
}finally {
exchange.endExchange();
}
}
_______________________________________________
undertow-dev mailing list
undertow-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/undertow-dev