On 10/04/2016 03:58 AM, Langer, Christoph wrote:
Hi,

I think I would also support replacing sun.net.ConnectionResetException with a 
publicly available java.net.ConnectionResetException that subclasses 
java.net.SocketException. But, as Chris mentions. a usage example would be 
helpful.

At present you're going to be hard-pressed to find exiting code that detects a connection reset IOException. The reason is that, while you *can* search for "Connection reset by peer" in the exception message, that text varies by platform and, more importantly, by locale. So it is essentially impossible to detect reliably.

But Norman's use case is dead on: a connection reset happens under common circumstances. In particular, when a TCP socket is closed by the peer before the peer has read all pending data, an RST is returned. This happens very often - when a peer process is terminated for example, or the peer encounters an unrelated exception and terminates the connection abruptly, both of which happen very, very commonly in networked applications. For servers the choice today is to fill the log with meaningless exception traces or lose potentially more serious problems (EIO for example is something that almost always indicates Bad Things).

I also support this proposal.

-----Original Message-----
From: net-dev [mailto:net-dev-boun...@openjdk.java.net] On Behalf Of Chris
Hegarty
Sent: Montag, 12. September 2016 17:07
To: Florian Weimer <fwei...@redhat.com>; Norman Maurer
<norman.mau...@googlemail.com>; net-dev@openjdk.java.net
Subject: Re: Introduce IOException subclass for ECONNRESET

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.

sun.net.ConnectionResetException 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.

-Chris.



--
- DML

Reply via email to