--- a/test/jdk/com/sun/jndi/ldap/RemoveNamingListenerTest.java Wed May 01 00:06:22 2019 -0700
+++ b/test/jdk/com/sun/jndi/ldap/RemoveNamingListenerTest.java Wed May 01 15:10:09 2019 +0100
@@ -134,7 +134,7 @@
private byte[] searchResponse = {0x30, 0x0C, 0x02, 0x01, 0x02, 0x65, 0x07, 0x0A, 0x01, 0x00, 0x04, 0x00, 0x04, 0x00};
public TestLDAPServer() throws IOException {
- super(new ServerSocket(0, 0, InetAddress.getLoopbackAddress()), true);
+ super(new ServerSocket(0, 0, InetAddress.getLoopbackAddress()));
setCommonRequestHandler((msg, out) -> {
switch (msg.getOperation()) {
case BIND_REQUEST:
--- a/test/jdk/com/sun/jndi/ldap/lib/BaseLdapServer.java Wed May 01 00:06:22 2019 -0700
+++ b/test/jdk/com/sun/jndi/ldap/lib/BaseLdapServer.java Wed May 01 15:10:09 2019 +0100
@@ -92,7 +92,6 @@
private ExecutorService workingPool;
private ConnectionHandler connectionHandler;
private SessionHandler sessionHandler;
- private boolean useDaemonThread = false;
enum DebugLevel {
FULL, // all debug message will be printed
@@ -114,30 +113,14 @@
}
/**
- * BaseLdapServer overload constructor with given server socket.
- *
- * @param serverSocket given server socket
- */
- public BaseLdapServer(ServerSocket serverSocket) {
- this(serverSocket, false);
- }
-
- /**
* BaseLdapServer constructor with given server socket and specify whether
* use daemon for each accept connection handling thread.
*
* @param serverSocket given server socket
- * @param useDaemonThread <tt>true</tt> if use daemon thread
*/
- public BaseLdapServer(ServerSocket serverSocket, boolean useDaemonThread) {
+ public BaseLdapServer(ServerSocket serverSocket) {
this.serverSocket = Objects.requireNonNull(serverSocket);
- this.useDaemonThread = useDaemonThread;
- if (useDaemonThread) {
- workingPool = Executors
- .newCachedThreadPool(new DefaultDaemonThreadFactory());
- } else {
- workingPool = Executors.newCachedThreadPool();
- }
+ workingPool = Executors.newCachedThreadPool();
try {
stackWalker = StackWalker.getInstance(RETAIN_CLASS_REFERENCE);
} catch (SecurityException se) {
@@ -201,19 +184,17 @@
isRunning = false;
workingPool.shutdown();
cleanupClosableRes(serverSocket);
- if (!useDaemonThread) {
- // let's cleanup thread pool
- synchronized (socketList) {
- socketList.forEach(BaseLdapServer::cleanupClosableRes);
+ // let's cleanup thread pool
+ synchronized (socketList) {
+ socketList.forEach(BaseLdapServer::cleanupClosableRes);
+ }
+ try {
+ if (!workingPool.awaitTermination(10, TimeUnit.SECONDS)) {
+ workingPool.shutdownNow();
}
- try {
- if (!workingPool.awaitTermination(10, TimeUnit.SECONDS)) {
- workingPool.shutdownNow();
- }
- } catch (InterruptedException e) {
- workingPool.shutdownNow();
- Thread.currentThread().interrupt();
- }
+ } catch (InterruptedException e) {
+ workingPool.shutdownNow();
+ Thread.currentThread().interrupt();
}
}
@@ -382,19 +363,6 @@
}
}
- class DefaultDaemonThreadFactory implements ThreadFactory {
-
- private ThreadFactory defaultThreadFactory = Executors
- .defaultThreadFactory();
-
- @Override
- public Thread newThread(Runnable r) {
- Thread thread = defaultThreadFactory.newThread(r);
- thread.setDaemon(true);
- return thread;
- }
- }
-
/**
* Default connection handler implementation.
*/