提交 fbdbc9ed 编写于 作者: A allwin

8004183: test/sun/management/jmxremote/LocalRMIServerSocketFactoryTest.java doesn't clean-up

Reviewed-by: sjiang, dfuchs, dholmes, olagneau, dholmes, jbachorik
上级 9d3cca2e
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2013 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -44,6 +44,7 @@ public class LocalRMIServerSocketFactoryTest {
private static final SynchronousQueue<Exception> queue =
new SynchronousQueue<Exception>();
private static volatile boolean isRunning = true;
static final class Result extends Exception {
......@@ -91,19 +92,23 @@ public class LocalRMIServerSocketFactoryTest {
Thread t = new Thread() {
public void run() {
while (true) {
while (isRunning) {
Exception error = Result.SUCCESS;
try {
System.err.println("Accepting: ");
final Socket ss = s.accept();
System.err.println(ss.getInetAddress() + " accepted");
} catch (Exception x) {
x.printStackTrace();
if (isRunning) {
x.printStackTrace();
}
error = x;
} finally {
try {
// wait for the client to get the exception.
queue.put(error);
if (isRunning) {
// wait for the client to get the exception.
queue.put(error);
}
} catch (Exception x) {
// too bad!
System.err.println("Could't send result to client!");
......@@ -114,32 +119,38 @@ public class LocalRMIServerSocketFactoryTest {
}
}
};
t.setDaemon(true);
t.start();
System.err.println("new Socket((String)null, port)");
final Socket s1 = new Socket((String) null, port);
checkError("new Socket((String)null, port)");
s1.close();
System.err.println("new Socket((String)null, port): PASSED");
System.err.println("new Socket(InetAddress.getByName(null), port)");
final Socket s2 = new Socket(InetAddress.getByName(null), port);
checkError("new Socket(InetAddress.getByName(null), port)");
s2.close();
System.err.println("new Socket(InetAddress.getByName(null), port): PASSED");
System.err.println("new Socket(localhost, port)");
final Socket s3 = new Socket("localhost", port);
checkError("new Socket(localhost, port)");
s3.close();
System.err.println("new Socket(localhost, port): PASSED");
System.err.println("new Socket(127.0.0.1, port)");
final Socket s4 = new Socket("127.0.0.1", port);
checkError("new Socket(127.0.0.1, port)");
s4.close();
System.err.println("new Socket(127.0.0.1, port): PASSED");
try {
t.start();
System.err.println("new Socket((String)null, port)");
final Socket s1 = new Socket((String) null, port);
checkError("new Socket((String)null, port)");
s1.close();
System.err.println("new Socket((String)null, port): PASSED");
System.err.println("new Socket(InetAddress.getByName(null), port)");
final Socket s2 = new Socket(InetAddress.getByName(null), port);
checkError("new Socket(InetAddress.getByName(null), port)");
s2.close();
System.err.println("new Socket(InetAddress.getByName(null), port): PASSED");
System.err.println("new Socket(localhost, port)");
final Socket s3 = new Socket("localhost", port);
checkError("new Socket(localhost, port)");
s3.close();
System.err.println("new Socket(localhost, port): PASSED");
System.err.println("new Socket(127.0.0.1, port)");
final Socket s4 = new Socket("127.0.0.1", port);
checkError("new Socket(127.0.0.1, port)");
s4.close();
System.err.println("new Socket(127.0.0.1, port): PASSED");
}
finally {
isRunning = false;
s.close();
t.join();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册