8233307: MulticastSocket getOption(IP_MULTICAST_IF) returns interface when not set

The MulticastSocket method getOption has been changed to conform to the behavior described in StandardSocketOptions.IP_MULTICAST_IF.

Reviewed-by: chegar, dfuchs
This commit is contained in:
Patrick Concannon 2019-11-28 16:49:52 +00:00
parent 558aadf608
commit 55da7d34c9
4 changed files with 150 additions and 67 deletions

View file

@ -576,7 +576,7 @@ public class MulticastSocket extends DatagramSocket {
public NetworkInterface getNetworkInterface() throws SocketException {
NetworkInterface ni
= (NetworkInterface)getImpl().getOption(SocketOptions.IP_MULTICAST_IF2);
if ((ni.getIndex() == 0) || (ni.getIndex() == -1)) {
if (ni == null) {
InetAddress[] addrs = new InetAddress[1];
addrs[0] = InetAddress.anyLocalAddress();
return new NetworkInterface(addrs[0].getHostName(), 0, addrs);