8243408: Inconsistent Exceptions are thrown by MulticastSocket when sending a DatagramPacket to port 0

This fix adds a check for port == 0 to MulticastSocket's 2-arg send method to ensure a consistent exception is thrown across platforms

Reviewed-by: dfuchs
This commit is contained in:
Patrick Concannon 2020-04-22 20:41:56 +01:00
parent 2785fe5621
commit 42d2a7411b
4 changed files with 146 additions and 6 deletions

View file

@ -797,6 +797,9 @@ public class MulticastSocket extends DatagramSocket {
// set the ttl
getImpl().setTTL(ttl);
}
if (packetPort == 0) {
throw new SocketException("Can't send to port 0");
}
// call the datagram method to send
getImpl().send(p);
} finally {