提交 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) {
if (isRunning) {
x.printStackTrace();
}
error = x;
} finally {
try {
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,7 +119,8 @@ public class LocalRMIServerSocketFactoryTest {
}
}
};
t.setDaemon(true);
try {
t.start();
System.err.println("new Socket((String)null, port)");
......@@ -140,6 +146,11 @@ public class LocalRMIServerSocketFactoryTest {
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.
先完成此消息的编辑!
想要评论请 注册