RFR: 8275319 java.net.NetworkInterface throws java.lang.Error instead of SocketException
Daniel Jeliński
duke at openjdk.java.net
Fri Oct 15 16:16:49 UTC 2021
On Fri, 15 Oct 2021 11:22:23 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
> we need to examine each of these on a case-by-case basis
Makes sense.
1. `MultiByteToWideChar` case: we can change this to `InternalError`, as it's not supposed to happen and apparently not happening
2. [GetIfTable](https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getiftable) case:
- as JDK-8165665 states, our handling of `ERROR_INSUFFICIENT_BUFFER` leaves something to be desired. We could keep allocating larger buffers a few more times, similar to what we have [here](https://github.com/openjdk/jdk/blob/2322f15d4c5bf1efbdc65eb4ec30662b30bf2d5e/src/java.base/windows/native/libnet/NetworkInterface_winXP.c#L92).
- `ERROR_INVALID_PARAMETER` qualifies as `InternalError` to me,
- `ERROR_NOT_SUPPORTED` is either a `SocketException` or an empty list.
- I'm a bit concerned about the "Other" catch-all qualifier on MSDN page, but I'd use `SocketException` for these, possibly with error code / name embedded in exception message. Since they are not explicitly enumerated by Microsoft, I don't see how they could qualify as Java bugs.
3. [GetIpAddrTable](https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getipaddrtable) case: documentation specifies exactly the same list of errors as above, so we could handle them in the same way
4. [GetAdaptersAddresses](https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses) case (winxp only - is the file really used only on WinXP?):
- `ERROR_ADDRESS_NOT_ASSOCIATED`: either return no data or throw `SocketException` to make it different from `ERROR_NO_DATA`
- `ERROR_BUFFER_OVERFLOW`: our handling looks fine here
- `ERROR_INVALID_PARAMETER`: `InternalError`
- `ERROR_NOT_ENOUGH_MEMORY`: OOME?
- `ERROR_NO_DATA`: return no data
- other: JDK-8217298 reports `ERROR_ACCESS_DENIED` (5), JDK-8231811 reports `ERROR_NOT_FOUND` (1168); I'd use `SocketException` for error codes in this category.
What do you think?
-------------
PR: https://git.openjdk.java.net/jdk/pull/5956
More information about the net-dev
mailing list