Skip to content

Commit 7d459c1

Browse files
j5ik2oj5ik2o-bot[bot]
authored andcommitted
refactor the lock object
1 parent 65c203c commit 7d459c1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docker-controller-scala-core/src/main/scala/com/github/j5ik2o/dockerController/RandomPortUtil.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import java.nio.channels.ServerSocketChannel
55

66
trait RandomPortUtil {
77

8-
def temporaryServerAddress(interface: String = "127.0.0.1"): InetSocketAddress = synchronized {
8+
def temporaryServerAddress(interface: String = "127.0.0.1"): InetSocketAddress = RandomPortUtil.synchronized {
99
val serverSocket = ServerSocketChannel.open()
1010
try {
1111
serverSocket.socket.bind(new InetSocketAddress(interface, 0))
@@ -14,7 +14,7 @@ trait RandomPortUtil {
1414
} finally serverSocket.close()
1515
}
1616

17-
def temporaryServerHostnameAndPort(interface: String = "127.0.0.1"): (String, Int) = synchronized {
17+
def temporaryServerHostnameAndPort(interface: String = "127.0.0.1"): (String, Int) = RandomPortUtil.synchronized {
1818
val socketAddress = temporaryServerAddress(interface)
1919
socketAddress.getHostName -> socketAddress.getPort
2020
}

0 commit comments

Comments
 (0)