RFR 8241305: Add protocol specific factory creation methods to SocketChannel and ServerSocketChannel
Daniel Fuchs
daniel.fuchs at oracle.com
Wed May 6 15:56:56 UTC 2020
Hi Michael,
java/nio/channels/OpenConnect.java
Why is the test using reflection?
Is it so that you can run it on a platform that doesn't have the
JEP implementation in?
Otherwise I like the formatting of the data provider: very clear!
It's a bit surprising to see that contrarily to SocketChannel,
DatagramChannel seems to have system dependent behaviors, but
I'm suspecting this is caused by passing wildcard addresses to
connect?
java/nio/channels/ProtocolFamilies.java
60 static final boolean preferIPv6 =
61
parseBoolean(getProperty("java.net.preferIPv6Addresses", "false"));
You could use IPSupport::preferIPv6Addresses there - it's been added
to IPSupport since that test was written.
101 if (expExType == UOE) {
102 assertThrows(UOE, () -> openSC(fam));
103 } else {
104 openSC(fam);
105 }
That's a strange pattern. I'd have expected something like:
101 if (expExType != null) {
102 assertThrows(expExType, () -> openSC(fam));
103 } else {
104 openSC(fam);
105 }
(this pattern appears at several places in this file)
395 private static Inet4Address getFirstLinkLocalIPv4Address()
396 throws Exception {
397 return NetworkConfiguration.probe()
398 .ip4Addresses()
399 .filter(a -> !a.isLoopbackAddress())
400 .findFirst()
401 .orElse(null);
402 }
The method above doesn't seem to be doing what its name
implies it does? It doesn't return the first link local
address but the first address that is not the loopback.
Link local addresses have proved to be problematic on
some macOS configuration.
I'm curious to know why would this test needs them?
best regards,
-- daniel
On 05/05/2020 12:16, Michael McMahon wrote:
> Hi,
>
> Could I get the following change reviewed please?
>
> The change is to add new static factory creation methods
> to java.nio.channels.SocketChannel and
> java.nio.channels.ServerSocketChannel
> which take a java.net.ProtocolFamily. These are basically the same as
> a similar method that was added to DatagramChannel back in 1.7
> and which allow the creation of IPv4 only channels or IPv4/IPv6.
>
> The change will also facilitate the 'Unix domain' protocol family work
> in JEP-380 [4]
>
> The webrev is at [1] The CSR for the spec change is at [2]
> and the bugid is [3].
>
> Thanks,
>
> Michael.
>
>
> [1] http://cr.openjdk.java.net/~michaelm/8241305/webrev.1/
>
> [2] https://bugs.openjdk.java.net/browse/JDK-8242926
>
> [3] https://bugs.openjdk.java.net/browse/JDK-8241305
>
> [4] https://openjdk.java.net/jeps/380
>
More information about the nio-dev
mailing list