On Tue, 19 Oct 2021 09:32:19 GMT, Daniel Jeliński <d...@openjdk.java.net> wrote:
>> Per Java documentation, >> "[Error](https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/Error.java#L30) >> [..] indicates serious problems that a reasonable application should not >> try to catch". Failure to enumerate network interfaces or addresses is not a >> serious enough situation; many applications can recover from this pretty >> easily. >> >> All native methods (except `init()`) in >> [NetworkInterface](https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/net/NetworkInterface.java#L436) >> are declared with `throws SocketException`, so throwing SocketExceptions >> instead of Errors will match the declared interface. >> >> Unix version of >> [NetworkInterface](https://github.com/openjdk/jdk/blob/master/src/java.base/unix/native/libnet/NetworkInterface.c#L1189) >> already throws `SocketException`s in similar situations, and does not throw >> `Error` under any circumstances. >> >> I searched the bug database and mail archives, but could not find any >> discussion on the topic; if there's a reason to keep throwing `Error`s, I >> couldn't find it. >> >> `tier1` tests pass, `java.net` tests pass. No new regression tests as I >> couldn't find any list of steps to reproduce the problem. >> >> I don't have write access to JBS. I could use some help with creating a >> ticket. > > Daniel Jeliński has updated the pull request incrementally with one > additional commit since the last revision: > > Adapt line length to 80 column display Hi - I have run your current patch through our CI and the good news is that we got no failure. However - we should probably go the extra mile and fix the case where -2 is returned. >In default mode the exception is swallowed here, and then SocketException ("No >network interfaces configured") is thrown in Java code. > The code that swallows exception appears incorrect; when exception is > swallowed, netifPP is null, last is null and the code that could add an IPv6 > interface would crash. I believe you are correct and there are still some issues in that case. In particular I also see -that if netaddrCount == -2 there: https://github.com/openjdk/jdk/blob/a6c89e231872e7fab236ed87b5ccf44a189d6786/src/java.base/windows/native/libnet/NetworkInterface_winXP.c#L573 we're going to try and allocate arrays of size -2 a few lines below. That doesn't sound right. ------------- PR: https://git.openjdk.java.net/jdk/pull/5956