JDK-6972374 : NetworkInterface.getNetworkInterfaces throws "java.net.SocketException" on Solaris zone
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-07-27
  • Updated: 2011-05-18
  • Resolved: 2011-05-18
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.
JDK 7
7 b105Fixed
Related Reports
Relates :  
Description
Test
	com/sun/jdi/ListenAddress.java

fails since JDK 7 b102 on Solaris 10 zone with

java.net.SocketException: No such device or address
        at java.net.NetworkInterface.getAll(Native Method)
        at java.net.NetworkInterface.getNetworkInterfaces(NetworkInterface.java:316)
        at ListenAddress.main(ListenAddress.java:93)
        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:613)
        at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:94)
        at java.lang.Thread.run(Thread.java:717)
Other static methods of NetworkInterface that returnes NetworkInterface was also affected.
To reproduce the problem a very simple java code could be used.

import java.net.*;

public class test {

    public static void main(String argv[]) {
        test t = new test();
        t.run();
    }

    public void run() {
        try {                                      
            for (int i = 1; i<10; i++) {
                if (NetworkInterface.getByIndex(i) != null) {
                    System.out.println(NetworkInterface.getByIndex(i).getName());
                } else {
                    System.out.println(i);
                    break;
                }
            }
        } catch (SocketException se) {
            se.printStackTrace();
        }
    }
}

Comments
EVALUATION Changeset: a8a79f5b669e Author: chegar Date: 2010-07-29 10:02 +0100 URL: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/a8a79f5b669e 6972374: NetworkInterface.getNetworkInterfaces throws "java.net.SocketException" on Solaris zone Reviewed-by: alanb, dsamersoff ! src/solaris/native/java/net/NetworkInterface.c
29-07-2010

EVALUATION The Solaris version of getFlags sets an Exception if the ioctl fails. When used in addif getFlags will fail when access to the virtual interface's parent is forbidden, i.e. in a zone. addif is called when iterating over interfaces in enumIPvXInterfaces, if an exception occurs it simply cleans up and returns, propagating the exception. getFalgs should not set an exception. All other calls to it check the return value and set an exception if appropriate.
27-07-2010