prevent connection leak when temporaryServerAddress throws
This commit is contained in:
parent
fccf596649
commit
64d832377b
1 changed files with 5 additions and 4 deletions
|
|
@ -13,10 +13,11 @@ object TestUtils {
|
|||
|
||||
def temporaryServerAddress(address: String = "127.0.0.1"): InetSocketAddress = {
|
||||
val serverSocket = ServerSocketChannel.open()
|
||||
serverSocket.socket.bind(new InetSocketAddress(address, 0))
|
||||
val port = serverSocket.socket.getLocalPort
|
||||
serverSocket.close()
|
||||
new InetSocketAddress(address, port)
|
||||
try {
|
||||
serverSocket.socket.bind(new InetSocketAddress(address, 0))
|
||||
val port = serverSocket.socket.getLocalPort
|
||||
new InetSocketAddress(address, port)
|
||||
} finally serverSocket.close()
|
||||
}
|
||||
|
||||
def verifyActorTermination(actor: ActorRef)(implicit system: ActorSystem): Unit = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue