Close fake server successfully when it was not used
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Tue, 14 Jul 2015 17:39:00 +0000 (19:39 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Tue, 14 Jul 2015 17:39:00 +0000 (19:39 +0200)
src/test/java/net/pterodactylus/fcp/fake/FakeTcpServer.java

index 67a1fdc..c8edbbe 100644 (file)
@@ -3,7 +3,6 @@ package net.pterodactylus.fcp.fake;
 import java.io.IOException;
 import java.net.ServerSocket;
 import java.util.List;
-import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicReference;
@@ -53,7 +52,10 @@ public class FakeTcpServer implements AutoCloseable {
 
        @Override
        public void close() throws IOException {
-               clientSocket.get().close();
+               TextSocket textSocket = clientSocket.get();
+               if (textSocket != null) {
+                       textSocket.close();
+               }
        }
 
 }