United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7076523 TEST_BUG: test/java/net/NetworkInterface/NetParamsTest.java can fail with NPE
JDK-7076523 : TEST_BUG: test/java/net/NetworkInterface/NetParamsTest.java can fail with NPE

Details
Type:
Bug
Submit Date:
2011-08-08
Status:
Closed
Updated Date:
2012-08-21
Project Name:
JDK
Resolved Date:
2012-08-21
Component:
core-libs
OS:
generic
Sub-Component:
java.net
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:

Sub Tasks

Description
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
messages:
command: main NetParamsTest
reason: Assumed action based on file name: run main NetParamsTest 
elapsed time (seconds): 0.007
STDOUT:
ce0:1 : 
	Status:  UP
	Hardware Address: 0:14:4f:50:ffffffa4:7d:
	Loopback: false
	Point to Point: false
	Virtual: true
STDERR:
java.lang.NullPointerException
	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)
=======

                                    

Comments
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());
                                     
2011-08-10
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
                                     
2011-08-10



Hardware and Software, Engineered to Work Together