8146482: [TESTBUG] java/net/SocketOption/OptionTest should only use multicast capable interfaces for multicast tests
authorsimonis
Thu, 07 Jan 2016 10:54:41 +0100
changeset 34889 9aac81c72779
parent 34888 e3161752067f
child 34890 0e8281ef3550
8146482: [TESTBUG] java/net/SocketOption/OptionTest should only use multicast capable interfaces for multicast tests Reviewed-by: chegar
jdk/test/java/net/SocketOption/OptionsTest.java
--- a/jdk/test/java/net/SocketOption/OptionsTest.java	Wed Jan 06 22:22:01 2016 -0800
+++ b/jdk/test/java/net/SocketOption/OptionsTest.java	Thu Jan 07 10:54:41 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -80,8 +80,11 @@
     static NetworkInterface getNetworkInterface() {
         try {
             Enumeration<NetworkInterface> nifs = NetworkInterface.getNetworkInterfaces();
-            if (nifs.hasMoreElements()) {
-                return (NetworkInterface)nifs.nextElement();
+            while (nifs.hasMoreElements()) {
+                NetworkInterface ni = (NetworkInterface)nifs.nextElement();
+                if (ni.supportsMulticast()) {
+                    return ni;
+                }
             }
         } catch (Exception e) {
         }