On Mon, Jul 16, 2018 at 12:16 PM Stan Rosenberg <stan.rosenberg@gmail.com> wrote:
On Sun, Jul 15, 2018 at 9:48 PM, Stuart Douglas <sdouglas@redhat.com> wrote:
If all you want to do is drop the connection then just scheduling a task that does exchange.getConnection().close() is fine, no HTTP response will be returned to the client.

That would imply exchange.getConnection().close() is thread-safe; just double-checking.

Yes.
 
 

If you want to actually send a response to the client then you are going to have to have some kind of lock/CAS that prevents your application from writing once the timeout has taken effect. 


​Makes sense, but that's custom logic; i.e., not available in the API, right?

Yes. The issue with including something like this in the core API is that every request has to pay the thread safety price even if they don't use it.
 

Are you using the Servlet API or the HttpServerExchange API? The best way to approach this is a bit different depending on what you are doing.

 HttpServerExchange API
​. Thanks!​

This is a bit harder to do in the general case. With Servlet you could just create a thread safe wrapper, where the wrapper basically disconnects from the underlying request on timeout. The Undertow native API is not designed around wrapping though, so it needs cooperation from the application to manage this.

If you know the application is only going to be writing data (and not setting headers) then you should be able to make this work via a ConduitFactory implementation that handles the locking, although if this is not the case then you are going to need some kind of external lock.

Stuart