File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
common/test/io/ktor/utils/io Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -662,6 +662,14 @@ open class ByteChannelSmokeTest : ByteChannelTestBase() {
662662 assertFailsWith<IOException > { ch.readByte() }
663663 }
664664
665+ @Test
666+ fun testReadRemainingAvailable () = runTest {
667+ ch.writeFully(byteArrayOf(1 , 2 , 3 ))
668+ ch.flush()
669+ val remaining = ch.readRemaining(3 ).remaining
670+ assertEquals(3 , remaining)
671+ }
672+
665673 private fun assertEquals (expected : Float , actual : Float ) {
666674 if (abs(expected - actual) > 0.000001f ) {
667675 kotlin.test.assertEquals(expected, actual)
Original file line number Diff line number Diff line change @@ -2153,8 +2153,7 @@ internal open class ByteBufferChannel(
21532153
21542154 val rc = readAsMuchAsPossible(buffer)
21552155 remaining - = rc
2156- readSuspend(1 )
2157- remaining > 0L && ! isClosedForRead
2156+ remaining > 0L && ! isClosedForRead && readSuspend(1 )
21582157 }
21592158
21602159 closedCause?.let { throw it }
You can’t perform that action at this time.
0 commit comments