Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2213880 | 6u30 | Robert Mckenna | P2 | Closed | Fixed | b08 |
JDK-2210715 | 6u29 | Robert Mckenna | P2 | Closed | Fixed | b01 |
JDK-2212372 | 6u27-rev | Robert Mckenna | P2 | Closed | Fixed | b20 |
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.
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.
- backported by
-
JDK-2210715 java.net.InterfaceAddress's equals method may throw NPE
- Closed
-
JDK-2212372 java.net.InterfaceAddress's equals method may throw NPE
- Closed
-
JDK-2213880 java.net.InterfaceAddress's equals method may throw NPE
- Closed
- relates to
-
JDK-6628576 InterfaceAddress.equals() NPE when broadcast field == null
- Closed