changeset 59810:6a82085fc61d

8238376: test/jdk/java/nio/channels/DatagramChannel/Loopback.java failing on multi-homed systems Reviewed-by: dfuchs
author alanb
date Mon, 10 Feb 2020 12:57:31 +0000
parents a42cdcd11ca4
children ff30bca14dc9
files test/jdk/java/nio/channels/DatagramChannel/Loopback.java
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/java/nio/channels/DatagramChannel/Loopback.java	Tue Jan 28 11:28:52 2020 +0100
+++ b/test/jdk/java/nio/channels/DatagramChannel/Loopback.java	Mon Feb 10 12:57:31 2020 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,9 @@
 import java.nio.channels.Selector;
 import java.util.List;
 import java.util.stream.Collectors;
-import static java.net.StandardProtocolFamily.*;
+import static java.net.StandardProtocolFamily.INET;
+import static java.net.StandardProtocolFamily.INET6;
+import static java.net.StandardSocketOptions.IP_MULTICAST_IF;
 import static java.net.StandardSocketOptions.IP_MULTICAST_LOOP;
 
 import jdk.test.lib.NetworkConfiguration;
@@ -106,6 +108,9 @@
             System.out.format("join %s @ %s%n", group.getHostAddress(), ni.getName());
             dc.join(group, ni);
 
+            System.out.format("set outgoing multicast interface to %s%n", ni.getName());
+            dc.setOption(IP_MULTICAST_IF, ni);
+
             // -- IP_MULTICAST_LOOP enabled --
 
             assertTrue(dc.getOption(IP_MULTICAST_LOOP), "IP_MULTICAST_LOOP not enabled");