Skip to content

Conversation

jrudolph
Copy link
Contributor

Also remove useless nesting / finally blocks, arrays do not need closing.

Fixes #553

Simpler variant of #820. WDYT, @pjfanning ?

Also remove useless nesting / finally blocks, arrays do not need closing.

Fixes apache#553
val bis = ByteStringInputStream(payload)
try {
decoder.decode(bis, Receiver)
decoder.decode(payload.compact.asInputStream, Receiver) // only compact ByteString supports InputStream with mark/reset
Copy link
Member

@pjfanning pjfanning Oct 10, 2025

Choose a reason for hiding this comment

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

I'm not against this generally. One edge case is a ByteString that has a backing array but a non-zero offset.
We can get a safe InputStream directly from those ByteStreams without compacting them (an InputStream that supports mark/reset). I think in practice such ByteStrings are rare. So if we agree that such ByteStrings are not worrying about then I'm happy enough to go with this change.

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.

Twitter Decoder cannot handle all InputStream implementations

2 participants