Skip to content

Flush CharsetDecoder to produce final chunk#2667

Merged
mpilquist merged 2 commits intotypelevel:mainfrom
rossabaker:issue-2664
Oct 6, 2021
Merged

Flush CharsetDecoder to produce final chunk#2667
mpilquist merged 2 commits intotypelevel:mainfrom
rossabaker:issue-2664

Conversation

@rossabaker
Copy link
Copy Markdown
Member

@rossabaker rossabaker commented Oct 5, 2021

Only necessary in a handful of non-UTF-8 charsets. Setting the last input flag on the final decode isn't sufficient: the decoder state must be flushed in a separate call.

Fixes #2664.

decoder.flush(out) match {
case res if res.isUnderflow =>
if (out.position() > 0) {
out.flip()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we need a (out: Buffer).flip() here to maintain JDK8 support.

@mpilquist mpilquist merged commit e345809 into typelevel:main Oct 6, 2021
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.

decodeWithCharset doesn't flush

2 participants