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

MulticastSocket getOption(IP_MULTICAST_IF) returns interface when not set

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 14
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      The behavior of a getOption method added in Java SE 9 is changed to conform to the specification of StandardSocketOptions.IP_MULTICAST_IF.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pconcannon Patrick Concannon
                Reporter:
                alanb Alan Bateman
                Reviewed By:
                Alan Bateman, Chris Hegarty, Daniel Fuchs
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: