Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KTOR-5252 Fix EOFException in read and readUtf8Line #3285

Merged
merged 5 commits into from Dec 6, 2022
Merged

KTOR-5252 Fix EOFException in read and readUtf8Line #3285

merged 5 commits into from Dec 6, 2022

Conversation

e5l
Copy link
Member

@e5l e5l commented Dec 5, 2022

No description provided.

@@ -1631,6 +1631,7 @@ internal open class ByteBufferChannel(

override suspend fun read(min: Int, consumer: (ByteBuffer) -> Unit) {
require(min >= 0) { "min should be positive or zero" }
if (min == 0) return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it really correct?
f.e. if we call it with min=0 and we have 5 bytes in channel, I think, that those should be consumed, no?
And in case there will be no bytes in channel I don't know what is expected behaviour - may be return or call consumer with empty buffer, any way, no suspension should happen to await more bytes.
So in my opinion, it should work like non-suspend readAvailable, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will check

}
} catch (_: EOFException) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not an expert of course, but I see this as something easy to break - is it possible to avoid it? or at least add a comment, on why it's ignored?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, it's ignored by the contract of the method

}
} catch (_: EOFException) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@e5l e5l merged commit bfde300 into main Dec 6, 2022
@e5l e5l deleted the e5l/eof-brc branch December 6, 2022 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants