Skip to content

Commit

Permalink
fixed test by letting the TcpHexDumper perform a gentle shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Feb 7, 2018
1 parent 2fbc938 commit e01a7b5
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class TcpHexDumper implements BeforeEachCallback, AfterEachCallback, Para

public void init(int port) throws IOException, InterruptedException {
if (serverSocket != null) {
stop();
stop(true);
}
serverSocket = new ServerSocket(port);
logger.info("Starting pool");
Expand Down Expand Up @@ -90,16 +90,17 @@ public void stop() throws IOException, InterruptedException {

public void stop(boolean await) throws IOException, InterruptedException {
serverSocket.close();
if (await)
if (await) {
pool.awaitTermination(shutdownTimeout, TimeUnit.SECONDS);
else
} else {
pool.shutdownNow();
}
logger.info("Stopped");
}

@Override
public void afterEach(ExtensionContext context) throws Exception {
stop();
stop(true);
}

@Override
Expand Down

0 comments on commit e01a7b5

Please sign in to comment.