RFR: JDK-8299475: Enhance SocketException by cause where it is missing in net and nio area [v2]

Alan Bateman alanb at openjdk.org
Tue Jan 3 08:49:52 UTC 2023


On Tue, 3 Jan 2023 08:29:13 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

>> We have a couple of places where a SocketException is thrown but the cause is omitted. It would be beneficial for example in error analysis not to throw away the cause (causing exception) but to add it to the created SocketException.
>
> Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision:
> 
>   do not enhance some internal exceptions

src/java.base/share/classes/java/net/Socket.java line 535:

> 533:             created = true;
> 534:         } catch (IOException e) {
> 535:             throw new SocketException(e.getMessage(), e);

For this one, you could `catch (SocketException e) { throw e; }` as the exception from the impl will be a SocketException anyway. That would help avoid the confusing cause.

-------------

PR: https://git.openjdk.org/jdk/pull/11813


More information about the nio-dev mailing list