[undertow-dev] Closing an UndertowOutputStream on broken pipe

Stuart Douglas sdouglas at redhat.com
Tue Jan 6 17:56:27 EST 2015


You are correct, this is a bug.

I think the channel should probably take note of the first exception, and then not do anything on close, or maybe the chunked stream should not throw an exception on close, as even though it is an error condition it will generally only happen when something else has already gone wrote, so throwing an exception is not overly helpful.

Stuart

----- Original Message -----
> From: "Toby Crawley" <toby at tcrawley.org>
> To: undertow-dev at lists.jboss.org
> Sent: Wednesday, 7 January, 2015 9:38:36 AM
> Subject: [undertow-dev] Closing an UndertowOutputStream on broken pipe
> 
> 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
> _______________________________________________
> undertow-dev mailing list
> undertow-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev
> 


More information about the undertow-dev mailing list