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

Daniel Fuchs daniel.fuchs at oracle.com
Tue Mar 31 14:08:57 UTC 2020


This looks good to me Patrick.

I'm happy to see that all implementations now have a consistent
and predictable behavior.

Also - as Alan noted - this is not really a behavioral change
as some subclass of IOException (or IOException itself) was
already thrown before.

+1

best regards,

-- daniel

On 31/03/2020 11:15, Patrick Concannon wrote:
> 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 nio-dev mailing list