From 1852649d0de3405fa6729105e43be21a0a742e8a Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Tue, 14 May 2019 09:25:16 +0200 Subject: [PATCH] Determine temporary ports with SocketUtils #23337 --- .../scala/akka/remote/Ticket1978CommunicationSpec.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/akka-remote/src/test/scala/akka/remote/Ticket1978CommunicationSpec.scala b/akka-remote/src/test/scala/akka/remote/Ticket1978CommunicationSpec.scala index bead8fa034..630e3117bc 100644 --- a/akka-remote/src/test/scala/akka/remote/Ticket1978CommunicationSpec.scala +++ b/akka-remote/src/test/scala/akka/remote/Ticket1978CommunicationSpec.scala @@ -66,10 +66,8 @@ object Configuration { provider: Option[ConfigSSLEngineProvider]) def getCipherConfig(cipher: String, enabled: String*): CipherConfig = { - val localPort, remotePort = { - val s = new java.net.ServerSocket(0); - try s.getLocalPort - finally s.close() + val (localPort, remotePort) = SocketUtil.temporaryServerAddresses(2, "127.0.0.1").map(_.getPort) match { + case Seq(local, remote) => (local, remote) } try { //if (true) throw new IllegalArgumentException("Ticket1978*Spec isn't enabled")