From: David ‘Bombe’ Roden Date: Wed, 15 Jul 2015 05:14:33 +0000 (+0200) Subject: Shutdown thread pool after use X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=e56b18df338bf4440f44783d169e4405d9e92f82;p=jFCPlib.git Shutdown thread pool after use --- diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index 3ea9570..35a2857 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -58,13 +58,13 @@ public class DefaultFcpClientTest { private static final String REQUEST_URI = "SSK@wtbgd2loNcJCXvtQVOftl2tuWBomDQHfqS6ytpPRhfw,7SHH53gletBVb9JD7nBsyClbLQsBubDPEIcwg908r7Y,AQACAAE/"; - private static int threadCounter = 0; + private int threadCounter = 0; + private final ExecutorService threadPool = + Executors.newCachedThreadPool(r -> new Thread(r, "Test-Thread-" + threadCounter++)); private final FakeTcpServer fcpServer; private final DefaultFcpClient fcpClient; public DefaultFcpClientTest() throws IOException { - ExecutorService threadPool = - Executors.newCachedThreadPool(r -> new Thread(r, "Test-Thread-" + threadCounter++)); fcpServer = new FakeTcpServer(threadPool); fcpClient = new DefaultFcpClient(threadPool, "localhost", fcpServer.getPort(), () -> "Test"); } @@ -72,6 +72,7 @@ public class DefaultFcpClientTest { @After public void tearDown() throws IOException { fcpServer.close(); + threadPool.shutdown(); } @Test(expected = ExecutionException.class)