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

Alan Bateman Alan.Bateman at oracle.com
Wed Aug 10 03:47:20 PDT 2011


Chris Hegarty wrote:

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()); Should this be parentName as I assume parent.getName will NPE here.

-Alan



More information about the net-dev mailing list