You need to sign in or sign up before continuing.
提交 94cee434 编写于 作者: A alanb

8015765: TEST_BUG:...

8015765: TEST_BUG: java/nio/channels/ServerSocketChannel/AdaptServerSocket.java failing intermittently
Reviewed-by: chegar, dholmes, alanb
Contributed-by: yiming.wang@oracle.com
上级 89db59b6
......@@ -35,7 +35,7 @@ import java.nio.charset.*;
public class AdaptServerSocket {
static java.io.PrintStream out = System.out;
static volatile boolean clientStarted = false;
static volatile Exception clientException = null;
static volatile Thread client = null;
......@@ -44,15 +44,14 @@ public class AdaptServerSocket {
{
Thread t = new Thread() {
public void run() {
try {
Socket so = new Socket();
try (Socket so = new Socket()) {
out.println("client: " + so);
clientStarted = true;
if (dally > 0)
Thread.sleep(dally);
so.connect(new InetSocketAddress(port));
if (Thread.interrupted()) {
out.println("client interrupted");
so.close();
return;
}
out.println("client: " + so);
......@@ -61,7 +60,6 @@ public class AdaptServerSocket {
a += 1;
so.getOutputStream().write(a);
out.println("client: wrote " + a);
so.close();
} catch (Exception x) {
if (x instanceof InterruptedException)
return;
......@@ -78,10 +76,11 @@ public class AdaptServerSocket {
static void test(int clientDally, int timeout, boolean shouldTimeout)
throws Exception
{
clientStarted = false;
out.println();
ServerSocketChannel ssc = ServerSocketChannel.open();
ServerSocket sso = ssc.socket();
try (ServerSocketChannel ssc = ServerSocketChannel.open();
ServerSocket sso = ssc.socket()) {
out.println("created: " + ssc);
out.println(" " + sso);
if (timeout != 0)
......@@ -91,8 +90,9 @@ public class AdaptServerSocket {
out.println("bound: " + ssc);
out.println(" " + sso);
startClient(sso.getLocalPort(), clientDally);
Thread.sleep(10);
while (!clientStarted) {
Thread.sleep(20);
}
Socket so = null;
try {
so = sso.accept();
......@@ -112,9 +112,8 @@ public class AdaptServerSocket {
if (b != a + 1)
throw new Exception("Read incorrect data");
out.println("server: read " + b);
sso.close();
}
}
client.interrupt();
client.join();
if (clientException != null)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册