mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
Migrate from deprecated ReceiveChannel.poll to ReceiveChannel.tryReceive
This commit is done to migrate to 1.6.0 coroutines (where this deprecation is a compilation error) GitOrigin-RevId: af427c9b637fe9fe5d11a7cd6f432c497e251899
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d470865253
commit
53ef27adc7
@@ -5,6 +5,7 @@ import com.google.protobuf.ByteString
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.channels.ClosedReceiveChannelException
|
||||
import kotlinx.coroutines.channels.ReceiveChannel
|
||||
import kotlinx.coroutines.channels.onClosed
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
@@ -51,14 +52,13 @@ class ChannelInputStream(private val readChannel: ReceiveChannel<ByteString>) :
|
||||
var chunk = carryChunk
|
||||
try {
|
||||
do {
|
||||
val nextChunk = readChannel.poll() ?: break
|
||||
val nextChunk = readChannel.tryReceive()
|
||||
.onClosed { if (it is CancellationException) throw IOException(it) }
|
||||
.getOrNull() ?: break
|
||||
chunk = chunk.concat(nextChunk)
|
||||
}
|
||||
while (true)
|
||||
}
|
||||
catch (e: CancellationException) {
|
||||
throw IOException(e)
|
||||
}
|
||||
finally {
|
||||
carryChunk = chunk
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user