RFR 8194260, Point-to-point interface should be excluded from java/net/ipv6tests/*
vyom tewari
vyom.tewari at oracle.com
Wed Apr 18 06:07:29 UTC 2018
Hi Felix,
latest code looks good to me, personally i prefer to throw exception
instead returning null, but i can see that old code was also returning
null. Hopping the code which invokes getFirstLocalIPv4Address,
getFirstLocalIPv6Addres already taken care of null.
Thanks,
Vyom
On Wednesday 18 April 2018 11:05 AM, Felix Yang wrote:
> Hi Chris and Wyom,
>
> fixed as commented. Updated webrev:
>
> http://cr.openjdk.java.net/~xiaofeya/8194260/webrev.01/
>
> Thanks,
> Felix
> On 2018/4/17 16:25, Chris Hegarty wrote:
>>> On 17 Apr 2018, at 04:34, Felix Yang <felix.yang at oracle.com> wrote:
>>> ...
>>> http://cr.openjdk.java.net/~xiaofeya/8194260/webrev.00/
>> Thanks for doing this Felix. Mainly looks good. Just a few comments.
>>
>> The old test runs on systems without IPv4 or IPv6 configured. So
>> I think the Optional `get` should be replaced with `orElse`. Either that
>> or update usage to check for the presence of a value in the Optional.
>>
>> The old test filters out the loopback address, in order to get “real”
>> addresses. I think we should preserve this behaviour. Other filtering
>> is done in the old tests too, but I don’t think it is really needed.
>>
>> ---
>> diff --git a/test/jdk/java/net/ipv6tests/Tests.java
>> b/test/jdk/java/net/ipv6tests/Tests.java
>> --- a/test/jdk/java/net/ipv6tests/Tests.java
>> +++ b/test/jdk/java/net/ipv6tests/Tests.java
>> @@ -178,26 +178,28 @@
>> }
>> public static Inet4Address getFirstLocalIPv4Address () {
>> - return getNetworkConfig().ip4Addresses()
>> - .findFirst()
>> - .get();
>> + return networkConfig.ip4Addresses()
>> + .filter(a -> !a.isLoopbackAddress())
>> + .findFirst()
>> + .orElse(null);
>> }
>> public static Inet6Address getFirstLocalIPv6Address () {
>> - return getNetworkConfig().ip6Addresses()
>> - .findFirst()
>> - .get();
>> + return networkConfig.ip6Addresses()
>> + .filter(a -> !a.isLoopbackAddress())
>> + .findFirst()
>> + .orElse(null);
>> }
>> + private static NetworkConfiguration networkConfig =
>> getNetworkConfig();
>> +
>> private static NetworkConfiguration getNetworkConfig() {
>> - NetworkConfiguration cfg = null;
>> try {
>> - cfg = NetworkConfiguration.probe();
>> + return NetworkConfiguration.probe();
>> } catch (IOException e) {
>> System.out.println("Failed to probe
>> NetworkConfiguration");
>> throw new RuntimeException(e);
>> }
>> - return cfg;
>> }
>> -Chris.
>
More information about the net-dev
mailing list