7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group

Chris Hegarty chris.hegarty at oracle.com
Tue Mar 15 02:28:29 PDT 2011

 > This is a small fix to the mulitcast support in DatagramChannel. If
 > someone creates a DatagramChannel without specifying the protocol
 > family then they get a DatagramChannel to an IPv6 socket if IPv6 is
 > enabled. If they then attempt to join an IPv4 multicast group then it
 > may succeed or may fail (the spec is clear that there is no guarantee 
 > that a channel to a socket in one protocol family can join a
 > multicast group with an address that corresponds to another protocol
 > family). When not supported then the exception today is not clear.
 > The change here ensures that IllegalArgumentException is thrown with
 > a clear message detail when not supported and for Linux, changes the
 > implementation to use Net.join4 rather than Net.join6 for this case.
 > The webrev with the changes is here:
 >  http://cr.openjdk.java.net/~alanb/7026376/webrev/

I'm fine with this change as is, but here are a few minor comments:

In DatagramChannelImpl.innerJoin() the
   else { throw new IllegalArgumentException("Address type not 
supported"); }
  seems unnecessary, but maybe ok if we expect support for new protocol 
families to be added DatagramChannelImpl.

I guess canJoin6WithIPv4Group and canIPv6SocketJoinIPv4Group don't have 
to be implemented as native methods, but they look fine.


 > Thanks,
 > Alan

More information about the nio-dev mailing list