On Tue, 19 Apr 2022 15:54:02 GMT, Michael McMahon <micha...@openjdk.org> wrote:

>> test/jdk/jdk/net/ExtendedSocketOption/DontFragmentTest.java line 44:
>> 
>>> 42:         StandardProtocolFamily fam = args[0].equals("ipv4") ? INET : 
>>> INET6;
>>> 43:         System.out.println("Family = " + fam);
>>> 44:         testDatagramChannel(args, fam);
>> 
>> Shouldn't there be a testcase for when DatagramChannel is opened using the 
>> no arg factory method `DatagramChannel.open()`?
>
> I'm not sure there is value in testing all of these permutations. 
> Distinguishing DatagramChannel and DatagramSocket probably made sense, but 
> it's all the same implementation under the hood.

1. `DatagramChannel.open()` => opens a dual socket unless 
`-Djava.net.preferIPv4Stack=true`, in which case it should be equivalent to 
`DatagramChannel.open(StandardProtocolFamily.INET)`
2. `DatagramChannel.open(StandardProtocolFamily.INET)` => opens an IPv4 socket
3. `DatagramChannel.open(StandardProtocolFamily.INET6)` => opens an IPv6 socket

So I believe it makes sense to test the no-arg constructor since that's the 
only way to open a dual socket.

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

PR: https://git.openjdk.java.net/jdk/pull/8245

Reply via email to