JDK-7076523 : [TEST_BUG]: test/java/net/NetworkInterface/NetParamsTest.java can fail with NPE
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-08-08
  • Updated: 2015-09-22
  • Resolved: 2012-08-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
6u111Fixed 7u4Fixed 8 b04Fixed
The test test/java/net/NetworkInterface/NetParamsTest.java can fail under certain circumstances. The test is merely printing out a bunch of information about network interfaces, and apparently it assumes that if an interface is virtual that it must have a non-null parent interface. This seems not to be the case when running within a Solaris Zone (where presumably all the network interfaces are virtual and have no parents).

The information from the test log is as follows:

# uname -a:
#   SunOS sc11136019 5.10 Generic_142909-17 sun4u sparc SUNW,Netra-T12
ACTION: main -- Failed. Execution failed: `main' threw exception: java.lang.NullPointerException
REASON: Assumed action based on file name: run main NetParamsTest 
TIME:   0.007 seconds
command: main NetParamsTest
reason: Assumed action based on file name: run main NetParamsTest 
elapsed time (seconds): 0.007
ce0:1 : 
	Status:  UP
	Hardware Address: 0:14:4f:50:ffffffa4:7d:
	Loopback: false
	Point to Point: false
	Virtual: true
	at NetParamsTest.printIF(NetParamsTest.java:48)
	at NetParamsTest.main(NetParamsTest.java:69)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at com.sun.javatest.regtest.MainAction$SameVMRunnable.run(MainAction.java:680)
	at java.lang.Thread.run(Thread.java:722)

SUGGESTED FIX --- 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 12:30:29 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: " + parentName); } System.out.println("\tMulticast: " + netif.supportsMulticast());

EVALUATION Changeset: af15e902cf08 Author: chegar Date: 2011-08-10 12:30 +0100 URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/af15e902cf08 7076523: TEST_BUG: test/java/net/NetworkInterface/NetParamsTest.java can fail with NPE Reviewed-by: alanb ! test/java/net/NetworkInterface/NetParamsTest.java