RFR: 8304286: java/net/SocketOption/OptionsTest.java failing after JDK-8302659

Alan Bateman alanb at openjdk.org
Fri Mar 17 07:04:18 UTC 2023


On Thu, 16 Mar 2023 20:17:06 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

>> Could you try something like to find an interface with an IP address configured:
>> 
>>         boolean preferIPv4 = Boolean.getBoolean("java.net.preferIPv4Stack");
>>         Class<? extends InetAddress> clazz = preferIPv4 ? Inet4Address.class : Inet6Address.class;
>>         var ni = NetworkInterface.networkInterfaces()
>>                 .filter(_ni -> _ni.inetAddresses().anyMatch(clazz::isInstance))
>>                 .findAny()
>>                 .orElse(null);
>
> Yeah, I had something like that before. With security manager installed it will only return the loopback interface, which is not usable for multicasting on Linux.
> 
> The test is using [this SecurityManager policy](https://github.com/openjdk/jdk/blob/master/test/jdk/java/net/SocketOption/options.policy), which only allows `connect` to `localhost`, so only loopback address will be visible on NetworkInterfaces because of [this check](https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/net/NetworkInterface.java#L143)

This test is for socket options rather than a SM test. Also SM is deprecated, for removal. It would be okay to update the test's policy file so that it isn't restricted to just the loopback.

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

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


More information about the net-dev mailing list