RFR: 8232513: java/net/DatagramSocket/PortUnreachable.java still fails intermittently with BindException
mark sheppard
macanaoire at hotmail.com
Wed Dec 4 18:57:11 UTC 2019
Hi Julia and Daniel,
I ran the test as a standalone under 8 and 13 and got the following
on windows 10
$ java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
$ java PortUnreachableTest
Attempting to recreate server socket with port: 64195
PortUnreachableTest.recreateServerSocket: returning socket == /XXX.XXX.0.211:64195 obtained at first attempt with no sleep
Exception in thread "main" java.net.SocketTimeoutException: Receive timed out
at java.net.DualStackPlainDatagramSocketImpl.socketReceiveOrPeekData(Native Method)
at java.net.DualStackPlainDatagramSocketImpl.receive0(Unknown Source)
at java.net.AbstractPlainDatagramSocketImpl.receive(Unknown Source)
at java.net.DatagramSocket.receive(Unknown Source)
at PortUnreachableTest.execute(PortUnreachableTest.java:136)
at PortUnreachableTest.main(PortUnreachableTest.java:151)
$ /cygdrive/c/JDK-INSTALLS/jdk-13/bin/java -version
openjdk version "13" 2019-09-17
OpenJDK Runtime Environment (build 13+33)
OpenJDK 64-Bit Server VM (build 13+33, mixed mode, sharing)
$ /cygdrive/c/JDK-INSTALLS/jdk-13/bin/java PortUnreachableTest
Attempting to recreate server socket with port: 60473
PortUnreachableTest.recreateServerSocket: returning socket == /XXX.XXX.0.211:60473 obtained at first attempt with no sleep
Exception in thread "main" java.net.SocketTimeoutException: Receive timed out
at java.base/java.net.DualStackPlainDatagramSocketImpl.socketReceiveOrPeekData(Native Method)
at java.base/java.net.DualStackPlainDatagramSocketImpl.receive0(DualStackPlainDatagramSocketImpl.java:124)
at java.base/java.net.AbstractPlainDatagramSocketImpl.receive(AbstractPlainDatagramSocketImpl.java:182)
at java.base/java.net.DatagramSocket.receive(DatagramSocket.java:815)
at PortUnreachableTest.execute(PortUnreachableTest.java:136)
at PortUnreachableTest.main(PortUnreachableTest.java:151)
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();
$ /cygdrive/c/JDK-INSTALLS/jdk-13/bin/java PortUnreachableTest
Attempting to recreate server socket with port: 58754
PortUnreachableTest.recreateServerSocket: returning socket == /XXX.XXX.0.211:58754 obtained at first attempt with no sleep
client received data packet Greetings from the server
msheppard at MSHEPPARD-PC /cygdrive/c/Users/Mark Sheppard/eclipse-workspace/AgentTester-FLIG-4026
$ java PortUnreachableTest
Attempting to recreate server socket with port: 55876
PortUnreachableTest.recreateServerSocket: returning socket == /XXX.XXX.0.211:55876 obtained at first attempt with no sleep
client received data packet Greetings from the server
might be worth considering that as an addition
regards
Mark
________________________________
From: net-dev <net-dev-bounces at openjdk.java.net> on behalf of Daniel Fuchs <daniel.fuchs at oracle.com>
Sent: Wednesday 4 December 2019 16:10
To: Julia Boes <julia.boes at oracle.com>; OpenJDK Network Dev list <net-dev at openjdk.java.net>
Subject: Re: RFR: 8232513: java/net/DatagramSocket/PortUnreachable.java still fails intermittently with BindException
Hi Julia,
Looks good to me - but is:
31 * @library /test/lib
actually needed?
best regards,
-- daniel
On 04/12/2019 15:40, Julia Boes wrote:
> Hi,
>
> The test PortUnreachable closes a DatagramSocket and tries to rebind it
> to the same port, this causes the test to fail rarely with a
> BindException (I did 500 test runs and couldn't observe a failure). To
> decrease the likelihood of this to happen, the fix increases the number
> of bind retries and test repeats.
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8232513
>
> Webrev: http://cr.openjdk.java.net/~jboes/webrevs/8232513/webrev.00/
>
> Regards,
>
> Julia
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/net-dev/attachments/20191204/d72e4813/attachment-0001.html>
More information about the net-dev
mailing list