From 749074cf958181b46f5291387c457ba36ddd7f6c Mon Sep 17 00:00:00 2001 From: Bruce Hamilton Date: Mon, 27 Jan 2025 10:05:27 +0100 Subject: [PATCH] KTOR-8051 Revert EOFException change --- .../common/src/io/ktor/utils/io/ByteReadChannelOperations.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ktor-io/common/src/io/ktor/utils/io/ByteReadChannelOperations.kt b/ktor-io/common/src/io/ktor/utils/io/ByteReadChannelOperations.kt index 65fc0519b1..e10169017b 100644 --- a/ktor-io/common/src/io/ktor/utils/io/ByteReadChannelOperations.kt +++ b/ktor-io/common/src/io/ktor/utils/io/ByteReadChannelOperations.kt @@ -460,9 +460,11 @@ public val ByteReadChannel.availableForRead: Int */ @OptIn(InternalAPI::class) public suspend fun ByteReadChannel.readFully(out: ByteArray, start: Int = 0, end: Int = out.size) { + if (end > start && isClosedForRead) throw EOFException("Channel is already closed") var offset = start while (offset < end) { if (readBuffer.exhausted()) awaitContent() + if (isClosedForRead) throw EOFException("Channel is already closed") val count = min(end - offset, readBuffer.remaining.toInt()) readBuffer.readTo(out, offset, offset + count)