RFR: JDK-8175325 - NetworkInterface.getInterfaceAddresses throws NPE when no addresses

Mark Sheppard mark.sheppard at oracle.com
Mon Mar 6 22:00:46 UTC 2017


Hi,
    please oblige and review the change
http://cr.openjdk.java.net/~msheppar/8175325/webrev/

for the issue raised in
https://bugs.openjdk.java.net/browse/JDK-8175325

the scenario is that a MulticastSocket, bound to a wildcard address, 
which has yet to have its NetworkInterface
set, will return a synthesized NetworkInterface for a 
getNetworkInterface method call. The newly constructed
has no InterfaceAddress bindings instantiated, resulting in a NPE when 
getInterfaceAddresses is invoked.
The fix initializes the bindings member variable with an empty array, as 
per suggestion in the bug, and also,
for completeness, places a null check in the getInterfaceAddresses method.

There is a side issue here, relating to the synthesis of a 
NetworkInterface for a MulticastSocket
bound to a wildcard address. This is somewhat dubious semantics, and 
would seem to be worthy of review
at some stage in the future.

regards
Mark


More information about the net-dev mailing list