Thanks Alan. On Tue, Jan 19, 2021 at 1:57 PM Alan Bateman <alan.bate...@oracle.com> wrote:
> On 19/01/2021 18:36, Vitaly Davidovich wrote: > > Hi all, > > A few colleagues and I were trying to make sense of the > joinGroup(SocketAddress, > NetworkInterface) > <https://github.com/openjdk/jdk/blob/05a764f4ffb8030d6b768f2d362c388e5aabd92d/src/java.base/share/classes/java/net/MulticastSocket.java#L382> > method. In particular: > > - Why does this take a SocketAddress and then ignores the port in the > implementation? Any reason it doesn't take InetAddress, which would make it > clear the port is unnecessary? The deprecated overload of joinGroup takes > an InetAddress (and is deprecated because it didn't allow specifying the > network interface). > > That was an API mistake in Java 1.4. When DatagramChannel was updated to > support joining multicast groups (in Java 7) it was able to get the > parameters right. > Would it make sense to make a note of this aspect in joinGroup's javadoc? > > > > - The MulticastSocket class javadoc still talks > > <https://github.com/openjdk/jdk/blob/05a764f4ffb8030d6b768f2d362c388e5aabd92d/src/java.base/share/classes/java/net/MulticastSocket.java#L45> > about using joinGroup(InetAddress) as the way to join a group. Should > probably be updated to mention the non-deprecated overload. > - Also in the class javadoc, there's a "stray" port variable > > <https://github.com/openjdk/jdk/blob/05a764f4ffb8030d6b768f2d362c388e5aabd92d/src/java.base/share/classes/java/net/MulticastSocket.java#L52> > that's not defined anywhere in the example. Since the port is ignored by > the joinGroup method, what is this port supposed to represent? > > Yes, the javadoc needs some TLC. > > -Alan > >