JDK-7041200 : java.net.InterfaceAddress's equals method may throw NPE
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-05-02
  • Updated: 2011-09-08
  • Resolved: 2011-05-31
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 Availabitlity Release.

To download the current JDK release, click here.
JDK 6
6u26-rev b22Fixed
Related Reports
Relates :  
Description
InterfaceAddress.equals contains this:

if ((address != null & cmp.address == null) ||
    (!address.equals(cmp.address)))
    return false;
if ((broadcast != null & cmp.broadcast == null) ||
    (!broadcast.equals(cmp.broadcast)))
    return false;

if address == null, or broadcast == null, NPE will be thrown.  broadcast ==
null can be tested by running this test:

try {
   Enumeration<NetworkInterface> networkInterfaces =
      NetworkInterface.getNetworkInterfaces();

   while (networkInterfaces.hasMoreElements()) {
      NetworkInterface networkInterface = networkInterfaces.nextElement();

      List<InterfaceAddress> interfaceAddresses =
         networkInterface.getInterfaceAddresses();

      for (InterfaceAddress interfaceAddress : interfaceAddresses) {
         interfaceAddress.equals(interfaceAddress);
      }
   }
} catch (SocketException ex) {
   ex.printStackTrace();
}

When the loopback interface address is reached, NPE will be thrown for the
broadcast test.  I'm not sure if you can get an interface address with a null
address.

This has been fixed in JDK 7.

Comments
EVALUATION Appears to be a dup of 6628576.
2011-05-03