As it was mentioned in other issues here, embedded-redis leaves orphaned child processes when parent is aborted without RedisServer#stop(). Someone reported such behavior on CI servers, but for me this is happening when I stop debugging from IDE (IntelliJ) in the middle of a test case.
Currently auto-termination of child processes is unsolved problem in Java (stackoverflow). Hopefully that will be fixed once Java 9 is live (JEP-102). Until then I suggest a couple of improvements:
Test if local port is available first and throw BindException if not. Let user define what to do in this case. In my case I've just decided to naively and blindly guess that there is already Redis up and running:
def isLocalPortAvailable(port: Int): Boolean = {
var portAvailable = true
var socket: ServerSocket = null
try {
socket = new ServerSocket(port)
} catch {
case e: BindException => portAvailable = false
} finally {
if (socket != null) {
socket.close()
}
}
portAvailable
}
Do not throw generic RuntimeException in AbstractRedisInstance, line 61. Just inherit something custom from runtime. It will be easier for end users to add custom handling logic
Add Runtime.getRuntime().addShutdownHook logic as suggested in mentioned above stackoverflow, which will cover some cases of process termination, like SIGINT
As it was mentioned in other issues here, embedded-redis leaves orphaned child processes when parent is aborted without
RedisServer#stop()
. Someone reported such behavior on CI servers, but for me this is happening when I stop debugging from IDE (IntelliJ) in the middle of a test case.Currently auto-termination of child processes is unsolved problem in Java (stackoverflow). Hopefully that will be fixed once Java 9 is live (JEP-102). Until then I suggest a couple of improvements:
AbstractRedisInstance
, line 61. Just inherit something custom from runtime. It will be easier for end users to add custom handling logicRuntime.getRuntime().addShutdownHook
logic as suggested in mentioned above stackoverflow, which will cover some cases of process termination, like SIGINT