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

Matthias Baesken mbaesken at openjdk.org
Wed Jan 4 11:43:59 UTC 2023


On Wed, 4 Jan 2023 10:00:51 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Hi Alan, I adjusted this coding following your suggestion to use setStackTrace.
>
>> Hi Alan, I adjusted this coding following your suggestion to use setStackTrace.
> 
> That's just one of them. In a later comment I pasted in asSocketException and changed all 4 cases to use it, maybe you could try that. The right thing is of course to drop the translation to SocketException as anything using read/write has to deal with IOException anyway, it's really just a concern that older code may having special handling of SocketException of undocumented, but longstanding, behavior in older JDK releases.

Sorry Alan, seems I somehow missed that. I pushed a new commit including asSocketException  .


I wonder, could asSocketException  in the form of asOtherException maybe be a useful generics that covers multiple exception classes (but that would be something for another PR) ?

public static <T extends Exception> T asOtherException(Exception e, T n) {
    ...
}

(maybe we could omit the second param somehow, not sure.)

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

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


More information about the nio-dev mailing list