[Gradle] Remove redundant thread-safety in BuildStatisticsWithKtorIT

This commit is contained in:
Alexander.Likhachev
2023-01-11 02:53:23 +01:00
committed by Space Team
parent 25004a4842
commit 32b98135a9
@@ -37,12 +37,9 @@ import kotlin.test.*
class BuildStatisticsWithKtorIT : KGPBaseTest() { class BuildStatisticsWithKtorIT : KGPBaseTest() {
companion object { companion object {
private val portSelectLock = java.util.concurrent.locks.ReentrantLock()
fun runWithKtorService(action: (Int) -> Unit) { fun runWithKtorService(action: (Int) -> Unit) {
var server: ApplicationEngine? = null var server: ApplicationEngine? = null
try { try {
portSelectLock.lock()
val port = getEmptyPort().localPort val port = getEmptyPort().localPort
server = embeddedServer(Netty, host = "localhost", port = port) server = embeddedServer(Netty, host = "localhost", port = port)
{ {
@@ -71,12 +68,8 @@ class BuildStatisticsWithKtorIT : KGPBaseTest() {
} }
}.start() }.start()
awaitInitialization(port) awaitInitialization(port)
portSelectLock.unlock()
action(port) action(port)
} finally { } finally {
if (portSelectLock.isLocked) {
portSelectLock.unlock()
}
server?.stop(1000, 1000) server?.stop(1000, 1000)
} }
} }