On 02/06/2015 14:37, Paul Sandoz wrote:
:
There is one small area of uncertainty with NetworkInterface. Can the following
method ever return null?
342 public static Enumeration<NetworkInterface> getNetworkInterfaces()
343 throws SocketException {
344 NetworkInterface[] netifs = getAll();
345
346 // specified to return null if no network interfaces
347 return netifs != null
348 ? enumerationFromArray(netifs)
349 : null;
350 }
Contrary to the comment i cannot find any specification. For the stream
returning method, networkInterfaces, i have specified this to return an empty
stream, thus it might be good to update the enumeration returning method as
well to say whether it returns null or an empty enumeration.
cc'ing net-dev. AFAIK, getNetworkInterface was originally specified to
return null but this was changed in Java SE 8 to always return with at
least one element, the loopback interface.
The underlying native getAll might still return null for exception cases
(which will cause the SocketException to be thrown on return). So I
think you can remove the null check.
-Alan