提交 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -44,6 +44,7 @@ public class LocalRMIServerSocketFactoryTest { ...@@ -44,6 +44,7 @@ public class LocalRMIServerSocketFactoryTest {
private static final SynchronousQueue<Exception> queue = private static final SynchronousQueue<Exception> queue =
new SynchronousQueue<Exception>(); new SynchronousQueue<Exception>();
private static volatile boolean isRunning = true;
static final class Result extends Exception { static final class Result extends Exception {
...@@ -91,19 +92,23 @@ public class LocalRMIServerSocketFactoryTest { ...@@ -91,19 +92,23 @@ public class LocalRMIServerSocketFactoryTest {
Thread t = new Thread() { Thread t = new Thread() {
public void run() { public void run() {
while (true) { while (isRunning) {
Exception error = Result.SUCCESS; Exception error = Result.SUCCESS;
try { try {
System.err.println("Accepting: "); System.err.println("Accepting: ");
final Socket ss = s.accept(); final Socket ss = s.accept();
System.err.println(ss.getInetAddress() + " accepted"); System.err.println(ss.getInetAddress() + " accepted");
} catch (Exception x) { } catch (Exception x) {
if (isRunning) {
x.printStackTrace(); x.printStackTrace();
}
error = x; error = x;
} finally { } finally {
try { try {
if (isRunning) {
// wait for the client to get the exception. // wait for the client to get the exception.
queue.put(error); queue.put(error);
}
} catch (Exception x) { } catch (Exception x) {
// too bad! // too bad!
System.err.println("Could't send result to client!"); System.err.println("Could't send result to client!");
...@@ -114,7 +119,8 @@ public class LocalRMIServerSocketFactoryTest { ...@@ -114,7 +119,8 @@ public class LocalRMIServerSocketFactoryTest {
} }
} }
}; };
t.setDaemon(true);
try {
t.start(); t.start();
System.err.println("new Socket((String)null, port)"); System.err.println("new Socket((String)null, port)");
...@@ -140,6 +146,11 @@ public class LocalRMIServerSocketFactoryTest { ...@@ -140,6 +146,11 @@ public class LocalRMIServerSocketFactoryTest {
checkError("new Socket(127.0.0.1, port)"); checkError("new Socket(127.0.0.1, port)");
s4.close(); s4.close();
System.err.println("new Socket(127.0.0.1, port): PASSED"); 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.
先完成此消息的编辑!
想要评论请 注册