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

Alan Bateman alanb at openjdk.org
Wed Jan 4 15:03:53 UTC 2023


On Wed, 4 Jan 2023 11:41:10 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

>>> 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.)

If there were other translations needed then it might be useful but I don't think we need it for this change.  So I think go with what you have now and we can re-visit it another time if needed, hopefully to remove it (at least for read/write) as the translation shouldn't be required.

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

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


More information about the nio-dev mailing list