Skip to content

Commit 754a19b

Browse files
author
Sergey Mashkov
committed
IO: fix writing byte packet
1 parent 7510117 commit 754a19b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

core/kotlinx-coroutines-io/src/main/kotlin/kotlinx/coroutines/experimental/io/ByteBufferChannel.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -949,9 +949,10 @@ internal class ByteBufferChannel(
949949
written = 0
950950
writing {
951951
val size = minOf(remaining(), node.readRemaining)
952-
if (!it.tryWriteExact(size)) throw IllegalStateException()
953-
written = node.read(this, size)
954-
bytesWritten(it, size)
952+
if (it.tryWriteExact(size)) {
953+
written = node.read(this, size)
954+
bytesWritten(it, size)
955+
}
955956
}
956957
} catch (t: Throwable) {
957958
node.release()

0 commit comments

Comments
 (0)