RFR[7021373]: DatagramPacket exception conditions are not clear

Alan Bateman Alan.Bateman at oracle.com
Fri Jan 24 12:26:39 UTC 2020


On 24/01/2020 11:49, Daniel Fuchs wrote:
>
> If I'm not mistaken, one side effect here is that this allows
> the DatagramSocketAdaptor to throw IllegalArgumentException when
> it is not connected and passed a DatagramPacket in which the port
> as not been set.
Yes, that's the outlier I mentioned in the reply (that usage should 
probably be changed anyway as the send shouldn't be create a SocketAddress).

> :
>
> I wonder if it might be more prudent to just keep and document
> the current behavior.
Maybe. We normally default to specifying the long standing behavior but 
there are cases where the risk of fixing an issue is very low, e.g 
DatagramSocket.send was changed recently to throw IAE for a case that 
was previously unspecified and where the implementation threw an 
accidental NPE.
-Alan.


More information about the net-dev mailing list