Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8023649

java.net.NetworkInterface.getInterfaceAddresses() call flow clean up

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version " 1.7.0_03 "
      Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
      Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      This is similar (if not a dup) to bug 7112820, however; I could not determine a way to re-open that one.

      We have an application which is doing the following:

      final Enumeration<NetworkInterface> inetEnum = NetworkInterface
      .getNetworkInterfaces();
       while (inetEnum.hasMoreElements()) {
        final NetworkInterface niFace = inetEnum.nextElement();
        if (niFace.isUp()) {
         final Enumeration<InetAddress> ipAddys = niFace.getInetAddresses();
      ...

      I get a NPE in my application when calling niFace.getInetAddresses().

      Stack trace:

        <exception>
          <message>java.lang.NullPointerException</message>
          <frame>
            <class>java.net.NetworkInterface</class>
            <method>getInterfaceAddresses</method>
            <line>160</line>
          </frame>
          <frame>
            <class>com.wbemsolutions.utilities.NetworkUtils</class>
            <method>getActiveIPs</method>
            <line>31</line>
          </frame>
        </exception>


      The line of code is this one:

      sec.checkConnect(bindings[j].getAddress().getHostAddress(), -1);

      In my case the 'binding' object contains a null at index 0

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Not getting a NPE

      REPRODUCIBILITY :
      This bug can be reproduced always.

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: