RFR[8240533]: 'Inconsistent Exceptions are thrown by DatagramSocket and DatagramChannel when sending a DatagramPacket to port 0.'
Alan Bateman
Alan.Bateman at oracle.com
Tue Mar 31 13:56:28 UTC 2020
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/
Attempting to send or connect to port 0 is an error and the long
standing behavior is to throw an IOException or SocketException so I
think this looks good.
-Alan.
More information about the net-dev
mailing list