Summary
Change implementation of MulticastSocket::getOption(StandardSocketOption.IP_MULTICAST_IF)
to return null
rather than a dummy object if the option has not been set.
Problem
MulticastSocket::getOption(StandardSocketOptions.IP_MULTICAST_IF)
returns a dummy NetworkInterface
object, instead of null
if the option has not been set.
By comparison, DatagramChannel
and DatagramChannel
's socket adaptor will return null
in the same circumstance, which is a much more intuitive behavior, and conforms to the behavior specified by StandardSocketOptions.IP_MULTICAST_IF:
The initial/default value of this socket option may be null to indicate that outgoing interface will be selected by the operating system, typically based on the network routing tables.
Solution
Change the return value of MulticastSocket::getOption(StandardSocketOptions.IP_MULTICAST_IF) to be null
if the option has not been set.
By long standing behavior, MulticastSocket::getNetworkInterface
returns a dummy interface when no network interface has been set. For backward compatibility and to avoid introducing unnecessary risks the behavior of this method will remain unchanged. Only the behavior of the MulticastSocket::getOption(StandardSocketOptions.IP_MULTICAST_IF)
method is changed. This method was added in Java SE 9 so the risks should be limited.
Specification
There is no change to the specification. However MulticastSocket::getOption(StandardSocketOptions.IP_MULTICAST_IF)
will now return null if the option has not been set, as specified by StandardSocketOptions.IP_MULTICAST_IF.
- csr of
-
JDK-8233307 MulticastSocket getOption(IP_MULTICAST_IF) returns interface when not set
-
- Closed
-