[undertow-dev] Closing an UndertowOutputStream on broken pipe

Toby Crawley toby at tcrawley.org
Tue Jan 6 17:38:36 EST 2015


I'm streaming data by writing it to an UndertowOutputStream in chunks,
and when the the client disconnects before the data is fully sent, I
get a Broken pipe IOException when calling .write() (which is
expected). I catch that error, then call .close() on the
UndertowOutputStream, which throws "java.io.IOException: UT000029:
Channel was closed mid chunk, if you have attempted to write chunked
data you cannot shutdown the channel until after it has all been
written."

Is this expected behavior? It seems like it wouldn't be, since none of
that pending data can be written.

Do I even need to close the OutputStream in this case? Would not doing
so leak any resources?

Currently, I'm catching and ignoring the IOException thrown by .close().

The full stack traces of the two errors are available at:
https://gist.github.com/21d111980352d04816c7

- Toby


More information about the undertow-dev mailing list