JDK-8235423 : MulticastSocket joinGroup/leaveGroup do not specify their behavior when the outgoing interface has not been set
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.net
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 14
  • Submitted: 2019-12-05
  • Updated: 2019-12-06
  • Resolved: 2019-12-06
Related Reports
CSR :  
Description
Summary
-------

MulticastSocket joinGroup/leaveGroup do not specify their behavior when the outgoing interface has not been set.

Problem
-------
The current javadoc is unclear on the behaviour of the 2-arg joinGroup/leaveGroup methods if null is given for the NetworkInterface parameter and no interface has been set. 
Similarly, the javadoc for the methods getInterface() and getNetworkInterface() do not specify what is returned when no NetworkInterface has previously been set.

Solution
--------
This fix clarifies the javadoc by describing the behaviour of the methods when null is passed for the NetworkInterface parameter for the 2-arg joinGroup/leaveGroup methods. It also clarifies what is returned from getInterface and getNetworkInterface when no NetworkInterface has been previously set. 

Specification
-------------

MulticastSocket::joinGroup


          * @param netIf specifies the local interface to receive multicast
          *        datagram packets, or {@code null} to defer to the interface set by
          *       {@link MulticastSocket#setInterface(InetAddress)} or
    -     *       {@link MulticastSocket#setNetworkInterface(NetworkInterface)}
    -     *
    +     *        {@link MulticastSocket#setNetworkInterface(NetworkInterface)}.
    +     *        If {@code null} is given and no interface has been set, the behaviour is
    +     *        unspecified: any interface may be selected or the operation may fail
    +     *        with a SocketException.


MulticastSocket::leaveGroup

          * @param netIf specifies the local interface or {@code null} to defer
    -     *             to the interface set by
    -     *             {@link MulticastSocket#setInterface(InetAddress)} or
    -     *             {@link MulticastSocket#setNetworkInterface(NetworkInterface)}
    +     *        to the interface set by {@link MulticastSocket#setInterface(InetAddress)}
    +     *        or {@link MulticastSocket#setNetworkInterface(NetworkInterface)}. If
    +     *        {@code null} is given and no interface has been set, the behaviour is
    +     *        unspecified: any interface may be selected or the operation may fail
    +     *        with a SocketException.

MulticastSocket::getInterface

         * @return An {@code InetAddress} representing
          *  the address of the network interface used for
    -     *  multicast packets.
    -     *
    +     *  multicast packets, or if no interface has been set,
    +     *  an {@code InetAddress} representing any local address.

MulticastSocket::getNetworkInterface


    -     * @return the multicast {@code NetworkInterface} currently set
    +     * @return The multicast {@code NetworkInterface} currently set. A placeholder
    +     *         NetworkInterface is returned when there is no interface set; it has
    +     *         a single InetAddress to represent any local address.






Comments
Moving to Approved.
06-12-2019

The approach is sound and has no compatibility impact. There is minor tweaking of the text for the `@return` tag suggested in the review on net-dev that has no impact on the substance/CSR.
06-12-2019

No problem. I've updated the CSR above to reflect the changes, and have sent out a link to the new webrev on the mailing list.
05-12-2019

Can you take this opportunity to replace `null` and `<i>null</i>` with `{@code null}` in the few places where null is mentioned in the API documentation in this file?
05-12-2019