提交 5b6daa19 编写于 作者: D dfuchs

8229421: The logic of java/net/ipv6tests/TcpTest.java is flawed

Summary: The test is fixed to ignore rogue client connection. However it remains succeptible to intermittent failures due to the use of the wildcad address.
Reviewed-by: dfuchs
Contributed-by: NPatrick Concannon <patrick.concannon@oracle.com>
上级 a65d71c7
......@@ -126,7 +126,19 @@ public class TcpTest extends Tests {
dprintln ("connecting to " + ia6addr);
c2 = new Socket ();
c2.connect (sadr6, 1000);
throw new RuntimeException ("connect to IPv6 address should be refused");
dprintln ("Unexpected successful connection: " + c2);
// Connect should fail with timeout exception. However, if something else is
// accepting connections, verify it is not our server.
server.setSoTimeout(500);
// Ok if accept() fails because of timeout
while (true) {
// acceptedSocket could be connected to c1, but not c2
try (Socket acceptedSocket = server.accept()) {
dprintln("accepted socket: " + acceptedSocket);
if (acceptedSocket.getRemoteSocketAddress().equals(c2.getLocalSocketAddress()))
throw new RuntimeException("connect to IPv6 address should be refused");
}
}
} catch (IOException e) { }
server.close ();
c1.close ();
......@@ -146,7 +158,19 @@ public class TcpTest extends Tests {
try {
dprintln ("connecting to " + ia4addr);
c2 = new Socket (ia4addr, port);
throw new RuntimeException ("connect to IPv4 address should be refused");
dprintln ("Unexpected successful connection: " + c2);
// Connect should fail with timeout exception. However, if something else is
// accepting connections, verify it is not our server.
server.setSoTimeout(500);
// Ok if accept() fails because of timeout
while (true) {
// acceptedSocket could be connected to c1, but not c2
try (Socket acceptedSocket = server.accept()) {
dprintln("accepted socket: " + acceptedSocket);
if (acceptedSocket.getRemoteSocketAddress().equals(c2.getLocalSocketAddress()))
throw new RuntimeException("connect to IPv4 address should be refused");
}
}
} catch (IOException e) { }
server.close ();
c1.close ();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册