Fix warnings related to OptIn/UseExperimental

This commit is contained in:
Alexander Udalov
2020-08-13 18:44:37 +02:00
parent 256f4449ce
commit 9b94e073af
14 changed files with 56 additions and 29 deletions
@@ -48,6 +48,7 @@ class CompileServiceClientSideImpl(
override fun startKeepAlives() {
val keepAliveMessage = Server.KeepAliveMessage<CompileServiceServerSide>()
@OptIn(ObsoleteCoroutinesApi::class)
GlobalScope.async(newSingleThreadContext("keepAliveThread")) {
delay(KEEPALIVE_PERIOD * 4)
while (true) {
@@ -5,24 +5,25 @@
package org.jetbrains.kotlin.daemon.common.experimental
import io.ktor.network.selector.ActorSelectorManager
import io.ktor.network.sockets.aSocket
import kotlinx.coroutines.*
import io.ktor.network.selector.*
import io.ktor.network.sockets.*
import io.ktor.util.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.jetbrains.kotlin.daemon.common.LoopbackNetworkInterface
import org.jetbrains.kotlin.daemon.common.experimental.socketInfrastructure.ServerSocketWrapper
import org.jetbrains.kotlin.daemon.common.*
import java.io.IOException
import java.io.Serializable
import java.net.*
import java.rmi.server.RMIClientSocketFactory
import java.rmi.server.RMIServerSocketFactory
import java.net.InetAddress
import java.net.InetSocketAddress
import java.util.*
object LoopbackNetworkInterfaceKtor {
val serverLoopbackSocketFactoryKtor by lazy { ServerLoopbackSocketFactoryKtor() }
val clientLoopbackSocketFactoryKtor by lazy { ClientLoopbackSocketFactoryKtor() }
@KtorExperimentalAPI
val selectorMgr = ActorSelectorManager(Dispatchers.IO)
class ServerLoopbackSocketFactoryKtor : Serializable {
@@ -30,6 +31,7 @@ object LoopbackNetworkInterfaceKtor {
override fun hashCode(): Int = super.hashCode()
@Throws(IOException::class)
@OptIn(KtorExperimentalAPI::class)
fun createServerSocket(port: Int) =
aSocket(selectorMgr)
.tcp()
@@ -37,6 +39,7 @@ object LoopbackNetworkInterfaceKtor {
}
class ClientLoopbackSocketFactoryKtor : LoopbackNetworkInterface.AbstractClientLoopbackSocketFactory<io.ktor.network.sockets.Socket>() {
@OptIn(KtorExperimentalAPI::class)
override fun socketCreate(host: String, port: Int): io.ktor.network.sockets.Socket =
runBlocking { aSocket(selectorMgr).tcp().connect(InetSocketAddress(host, port)) }
}
@@ -63,4 +66,4 @@ fun findPortForSocket(attempts: Int, portRangeStart: Int, portRangeEnd: Int): Se
}
}
throw IllegalStateException("Cannot find free socketPort in $attempts attempts", lastException)
}
}
@@ -1,3 +1,8 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common.experimental.socketInfrastructure
import io.ktor.network.sockets.Socket
@@ -114,6 +119,7 @@ abstract class DefaultAuthorizableClient<ServerType : ServerBase>(
return actualResult as T
}
@OptIn(ObsoleteCoroutinesApi::class, ExperimentalCoroutinesApi::class)
override suspend fun connectToServer() {
writeActor = GlobalScope.actor(capacity = Channel.UNLIMITED) {
@@ -1,3 +1,8 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common.experimental.socketInfrastructure
import io.ktor.network.sockets.ServerSocket
@@ -1,9 +1,15 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common.experimental.socketInfrastructure
import io.ktor.network.sockets.Socket
import io.ktor.network.sockets.openReadChannel
import io.ktor.network.sockets.openWriteChannel
import kotlinx.coroutines.*
import io.ktor.network.sockets.*
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.actor
import kotlinx.coroutines.channels.consumeEach
@@ -45,6 +51,7 @@ class ByteReadChannelWrapper(readChannel: ByteReadChannel, private val log: Logg
}
// TODO : replace GlobalScope with something more explicit here and below.
@OptIn(ObsoleteCoroutinesApi::class, ExperimentalCoroutinesApi::class)
private val readActor = GlobalScope.actor<ReadQuery>(capacity = Channel.UNLIMITED) {
consumeEach { message ->
if (!readChannel.isClosedForRead) {
@@ -145,6 +152,7 @@ class ByteWriteChannelWrapper(writeChannel: ByteWriteChannel, private val log: L
}
}
@OptIn(ObsoleteCoroutinesApi::class, ExperimentalCoroutinesApi::class)
private val writeActor = GlobalScope.actor<WriteActorQuery>(capacity = Channel.UNLIMITED) {
consumeEach { message ->
if (!writeChannel.isClosedForWrite) {