mirror of
https://github.com/corda/corda.git
synced 2024-12-19 13:08:04 +00:00
Testing: Make PortAllocation set SO_REUSEADDR to avoid CI conflicts
This commit is contained in:
parent
116bb7c1ba
commit
3854fec17f
@ -20,10 +20,7 @@ import com.typesafe.config.ConfigRenderOptions
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.File
|
||||
import java.net.ServerSocket
|
||||
import java.net.Socket
|
||||
import java.net.SocketException
|
||||
import java.net.URLClassLoader
|
||||
import java.net.*
|
||||
import java.nio.file.Paths
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
@ -95,7 +92,13 @@ sealed class PortAllocation {
|
||||
override fun nextPort() = portCounter++
|
||||
}
|
||||
class RandomFree(): PortAllocation() {
|
||||
override fun nextPort() = ServerSocket(0).use { it.localPort }
|
||||
override fun nextPort(): Int {
|
||||
return ServerSocket().use {
|
||||
it.reuseAddress = true
|
||||
it.bind(InetSocketAddress.createUnresolved("localhost", 0))
|
||||
it.localPort
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user