RFR: 8232513: java/net/DatagramSocket/PortUnreachable.java still fails intermittently with BindException
Julia Boes
julia.boes at oracle.com
Fri Dec 6 12:29:03 UTC 2019
Hi Mark,
> The test has a potential problem, that is the socket close can
> cause the attempted send from server socket to client not to occur.
>
> the sock.send() can result in the application data being copied into the
> kernel and queued for sending. But the send may not take place
> immediately.
> The data may not yet be sent when immediate close()
> is executed causing the socket's buffers and data to be released
> without sending.
>
> lines 24 etc
> DatagramSocket sock = recreateServerSocket(serverPort);
> b = "Greetings from the server".getBytes();
> packet = new DatagramPacket(b, b.length, addr, clientPort);
> sock.send(packet);
> sock.close();
>
> placing a small delay before the close appears to allow the send to
> take place
> DatagramSocket sock = recreateServerSocket(serverPort);
> b = "Greetings from the server".getBytes();
> packet = new DatagramPacket(b, b.length, addr, clientPort);
> sock.send(packet);
> Thread.sleep(1000);
> sock.close();
Thanks for the insight. I wasn't able to observe the SocketTimeout on
Windows but that sounds reasonable. I added a Thread.sleep(1000) before
sock.close().
Updated webrev: http://cr.openjdk.java.net/~jboes/webrevs/8232513/webrev.01/
Best,
Julia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/net-dev/attachments/20191206/7b0aa58d/attachment.html>
More information about the net-dev
mailing list