On Jun 3, 2015, at 12:46 PM, Alan Bateman <alan.bate...@oracle.com> wrote:
> 
> 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.
> 

Ok, i removed it but added an assert for the array being non-null and 
containing at least one element. I also refined the documentation of the stream 
returning method in light of this:

  
http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8081678-enumeration-and-stream/webrev/

Paul.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to