JDK-8278122 : Several network tests fail on Windows if no IPv6 is configured on network interface
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 17,18
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows
  • CPU: generic
  • Submitted: 2021-12-02
  • Updated: 2021-12-03
  • Resolved: 2021-12-03
Related Reports
Duplicate :  
Description
We see the below tests failing on several of our test machines, the windows installations all are able to support IPv6 but have no IPV6 addresses configured on their network interfaces.
The tests pass on other machines that have at least a link local ipv6 address configured.

java/nio/channels/DatagramChannel/AdaptorMulticasting.java
java/nio/channels/DatagramChannel/Loopback.java
java/net/DatagramSocket/DatagramSocketExample.java
java/net/DatagramSocket/DatagramSocketMulticasting.java
java/net/MulticastSocket/IPMulticastIF.java
java/net/MulticastSocket/JoinLeave.java
java/net/MulticastSocket/NoSetNetworkInterface.java

DatagramSocketExample throes this exception for excample:
java.net.SocketException: Invalid argument: 
	at java.base/sun.nio.ch.Net.setInterface6(Native Method)
	at java.base/sun.nio.ch.DatagramChannelImpl.setOption(DatagramChannelImpl.java:364)
	at java.base/sun.nio.ch.DatagramSocketAdaptor.setOption(DatagramSocketAdaptor.java:420)
	at java.base/java.net.DatagramSocket.setOption(DatagramSocket.java:1194)
	at DatagramSocketExample.test(DatagramSocketExample.java:132)
	at DatagramSocketExample.main(DatagramSocketExample.java:83)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:577)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:833)

It might be caused by the network code detecting that the OS is IPv6 capable but windows does not allow to use IPv6 socket options for IPv4 only sockets.

Comments
I took a look at JDK-8272476 and it is the same issue. I will close this as duplicate.
03-12-2021

This is probably a dup of JDK-8272476. The configuration is unusual and JDK-8272476 lists a few workarounds. I have a tentative patch but not planning to propose it for JDK 18 as it will take time to bake (there are subtle interactions with getOption).
02-12-2021