Repository navigation
THRIFT-6562: Report EOF from Ruby BufferedTransport when the wrapped read ends - #4197
Merged
Merged
Conversation
…read ends Client: rb BufferedTransport stored the wrapped transport's read result as its buffer without checking it. IOStreamTransport returns nil at the end of its input, as IO#read does, so read_all, read_byte and read_into_buffer raised NoMethodError there instead of a TransportException. An empty string from the wrapped transport made read_byte return nil and read_into_buffer raise TypeError. A nil refill now becomes an empty buffer, so read returns an empty string and read_all reports END_OF_FILE. read_byte and read_into_buffer raise END_OF_FILE when a refill is empty instead of reading past the buffer. Generated-By: amp/0.0.1794916837-g564d50 (model: anthropic/claude-opus-5-5; operator: kpumuk@apache.org)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thrift::BufferedTransportrefills its read buffer from the wrapped transport and then slices or indexes the result without checking it.IOStreamTransport#readdelegates to RubyIO#read, which returnsnilat the end of input, soread_all,read_byteandread_into_bufferraisedNoMethodErrorthere. A bareIOStreamTransportalready raisesThrift::TransportException(END_OF_FILE) in the same situation. When the wrapped transport returned an empty string at the end of input instead,read_bytereturnednilandread_into_bufferraisedTypeError.With this change:
readtreats anilrefill as an empty buffer and returns an empty string, soread_allraisesEND_OF_FILE. Partial reads work as before.read_byteandread_into_bufferraiseEND_OF_FILEwhen a refill isnilor empty, instead of reading past the buffer.Reproduction, run from
lib/rbwithbundle exec ruby -Ilib -Iext repro.rb:Before, on master
50242d7ea1:After:
The new specs in
spec/buffered_transport_spec.rbcover each method overIOStreamTransportand over a transport that returns an empty string at the end of input. The behavior is the same with and without the native extension.