Code Review 7076523: TEST_BUG: test/java/net/NetworkInterface/NetParamsTest.java can fail with NPE

Chris Hegarty chris.hegarty at oracle.com
Wed Aug 10 03:40:26 PDT 2011


An minor test issue seen when running on a virtual instance. Parent can 
legitimately be null, so the test should be robust enough to handle this.

 > : hg diff NetParamsTest.java
diff -r cf203f293b4e test/java/net/NetworkInterface/NetParamsTest.java
--- a/test/java/net/NetworkInterface/NetParamsTest.java Tue Aug 09 
16:59:44 2011 +0100
+++ b/test/java/net/NetworkInterface/NetParamsTest.java Wed Aug 10 
11:34:08 2011 +0100
@@ -45,7 +45,9 @@ public class NetParamsTest {
          System.out.println("\tPoint to Point: " + netif.isPointToPoint());
          System.out.println("\tVirtual: " + netif.isVirtual());
          if (netif.isVirtual()) {
-            System.out.println("\tParent Interface: " + 
netif.getParent().getName());
+            NetworkInterface parent = netif.getParent();
+            String parentName = parent == null ? "null" : parent.getName();
+            System.out.println("\tParent Interface: " + parent.getName());
          }
          System.out.println("\tMulticast: " + netif.supportsMulticast());

-Chris.



More information about the net-dev mailing list