[rdct-tests] introduce a port provider that makes sure the random port is requested from different diapasons

that is useful when several ports are requested in one test before they are actually used

GitOrigin-RevId: 0481897e66caec455aa932cff182d4a3afced49d
This commit is contained in:
Anastasia Katsman
2024-07-18 18:13:27 +02:00
committed by intellij-monorepo-bot
parent 0273a7bcdb
commit 272ead5603

View File

@@ -9,8 +9,6 @@ import com.intellij.tools.launch.os.ProcessOutputStrategy
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
import org.jetbrains.jps.model.java.JpsJavaClasspathKind
import java.net.InetAddress
import java.net.ServerSocket
object Launcher {
@Suppress("SSBasedInspection")
@@ -62,14 +60,4 @@ object Launcher {
return IdeLauncher.launchCommand(localLauncherFactory, ideLaunchContext).process to null
}
}
fun findFreePort(): Int {
synchronized(this) {
val socket = ServerSocket(0, 0, InetAddress.getByName("127.0.0.1"))
val result = socket.localPort
socket.reuseAddress = true
socket.close()
return result
}
}
}