Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8234811

MulticastSocket getOption(IP_MULTICAST_IF) returns interface when not set

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 14
    • core-libs
    • None
    • behavioral
    • low
    • The behavior of a getOption method added in Java SE 9 is changed to conform to the specification of StandardSocketOptions.IP_MULTICAST_IF.
    • Java API
    • SE

      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.

            pconcannon Patrick Concannon (Inactive)
            alanb Alan Bateman
            Alan Bateman, Chris Hegarty, Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: