diff --git a/src/main/java/redis/embedded/AbstractRedisInstance.java b/src/main/java/redis/embedded/AbstractRedisInstance.java index f8d2fbf8..abeae789 100644 --- a/src/main/java/redis/embedded/AbstractRedisInstance.java +++ b/src/main/java/redis/embedded/AbstractRedisInstance.java @@ -17,7 +17,7 @@ abstract class AbstractRedisInstance implements Redis { private Process redisProcess; private final int port; - private final ExecutorService executor = Executors.newSingleThreadExecutor(); + private ExecutorService executor; protected AbstractRedisInstance(int port) { this.port = port; @@ -47,6 +47,7 @@ private void logErrors() { final InputStream errorStream = redisProcess.getErrorStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(errorStream)); Runnable printReaderTask = new PrintReaderRunnable(reader); + executor = Executors.newSingleThreadExecutor(); executor.submit(printReaderTask); } @@ -78,6 +79,9 @@ private ProcessBuilder createRedisProcessBuilder() { @Override public synchronized void stop() throws EmbeddedRedisException { if (active) { + if (executor != null && !executor.isShutdown()) { + executor.shutdown(); + } redisProcess.destroy(); tryWaitFor(); active = false;