8164815: 3 JCK NetworkInterface tests fail on Raspberry Pi
authormsheppar
Fri, 11 Nov 2016 13:11:27 +0000
changeset 41969 e4c2f100927f
parent 41968 e96e3e4e8af5
child 41970 4128b2c679bd
8164815: 3 JCK NetworkInterface tests fail on Raspberry Pi Reviewed-by: chegar, alanb
jdk/src/java.base/share/classes/java/net/NetworkInterface.java
--- a/jdk/src/java.base/share/classes/java/net/NetworkInterface.java	Fri Nov 11 05:55:45 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/net/NetworkInterface.java	Fri Nov 11 13:11:27 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -335,15 +335,19 @@
      * {@link #getInetAddresses()} to obtain all IP addresses for this node
      *
      * @return an Enumeration of NetworkInterfaces found on this machine
-     * @exception  SocketException  if an I/O error occurs.
+     * @exception  SocketException  if an I/O error occurs,
+     *             or if the platform does not have at least one configured
+     *             network interface.
      * @see #networkInterfaces()
      */
     public static Enumeration<NetworkInterface> getNetworkInterfaces()
         throws SocketException {
         NetworkInterface[] netifs = getAll();
-        assert netifs != null && netifs.length > 0;
-
-        return enumerationFromArray(netifs);
+        if (netifs != null && netifs.length > 0) {
+            return enumerationFromArray(netifs);
+        } else {
+            throw new SocketException("No network interfaces configured");
+        }
     }
 
     /**
@@ -361,15 +365,19 @@
      * }</pre>
      *
      * @return a Stream of NetworkInterfaces found on this machine
-     * @exception  SocketException  if an I/O error occurs.
+     * @exception  SocketException  if an I/O error occurs,
+     *             or if the platform does not have at least one configured
+     *             network interface.
      * @since 9
      */
     public static Stream<NetworkInterface> networkInterfaces()
         throws SocketException {
         NetworkInterface[] netifs = getAll();
-        assert netifs != null && netifs.length > 0;
-
-        return streamFromArray(netifs);
+        if (netifs != null && netifs.length > 0) {
+            return streamFromArray(netifs);
+        }  else {
+            throw new SocketException("No network interfaces configured");
+        }
     }
 
     private static <T> Enumeration<T> enumerationFromArray(T[] a) {