package org.webbitserver.netty;

import java.util.Set;
import java.util.concurrent.Executors;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class NettyWebServerTest {
    @Test
    public void stopsServerCleanlyNotLeavingResourcesHanging() throws Exception {
        int threadCountStart = getCurrentThreadCount();
        NettyWebServer server = new NettyWebServer(Executors.newSingleThreadScheduledExecutor(), 8080).start();
        assertEquals(threadCountStart+1, getCurrentThreadCount());
        server.stop();
        assertEquals(threadCountStart, getCurrentThreadCount());
    }

    private int getCurrentThreadCount() {
        Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
        Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]);
        return threadArray.length;
    }

}
@@ -668,31 +668,14 @@
     
-Set%3CThread%3E threadSet =
+return
  Thr
@@ -710,123 +710,15 @@
 et()
-;%0A        Thread%5B%5D threadArray = threadSet.toArray(new Thread%5BthreadSet.size()%5D);%0A        return threadArray.length
+.size()
 ;%0A  

Optimise imports