Introduce IOException subclass for ECONNRESET

Chris Hegarty chris.hegarty at
Mon Sep 12 15:06:34 UTC 2016

On 12/09/16 14:50, Florian Weimer wrote:
> On 08/23/2016 09:40 AM, Norman Maurer wrote:
>> Hi all,
>> I first asked this on nio-dev[0] but was asked to move this over to here:
>> I wonder if it would be possible to add a new IOException sub-class
>> for ECONNRESET. Often you receive these errors if a remote peer closed
>> the connection and you try to read from it while using NIO. This is
>> very often not really something that concerns people and can just be
>> handled the same as a “normal close”.

So what are the other cases, where ECONNRESET may occur? What is
equivalent on non-Unix platforms, Windows for example?

 >> At the moment the only way to
>> detect this is to inspect the IOException message which is really
>> hacky.

Do you have examples of code that does this today?

>> I wonder if we could not add a special IOException sub-class
>> for this. Something like:
>> ConnectionResetException extends IOException {
>> }
> Shouldn't it be a subclass of SocketException?

I think it would have to be a subclass of SocketException too, for
compatibility at least, since that is the type that is thrown
today. exists today, but I don't think
that it ever finds its way outside of the implementation. And is
of course not part of Java SE.


More information about the net-dev mailing list