RFR[8240533]: 'Inconsistent Exceptions are thrown by DatagramSocket and DatagramChannel when sending a DatagramPacket to port 0.'

Patrick Concannon patrick.concannon at oracle.com
Tue Mar 31 10:15:44 UTC 2020


Hi,

Could someone please review my fix for JDK-8240533 'Inconsistent 
Exceptions are thrown by DatagramSocket and DatagramChannel when sending 
a DatagramPacket to port 0.' ?

Currently, DatagramSocket throws an IOException when sending to port 0, 
and doesn't throw when connecting. DatagramChannel currently throws a 
BindException in both cases.
The fix adds checks for port == 0 to the send and connect methods in 
DatagramSocket and DatagramChannelImpl. This is to ensure that 
consistent Exceptions i.e. SocketExceptions are thrown when trying to 
connect or send to port 0.


bug: https://bugs.openjdk.java.net/browse/JDK-8240533
webrev: http://cr.openjdk.java.net/~pconcannon/8240533/webrevs/webrev.00/


Kind regards,

Patrick


More information about the net-dev mailing list