kpumuk commented on code in PR #3702:
URL: https://github.com/apache/thrift/pull/3702#discussion_r3720485300
##########
lib/rb/lib/thrift/transport/memory_buffer_transport.rb:
##########
@@ -23,13 +23,8 @@ module Thrift
class MemoryBufferTransport < BaseTransport
GARBAGE_BUFFER_SIZE = 4*(2**10) # 4kB
- # If you pass a string to this, you should #dup that string
- # unless you want it to be modified by #read and #write
- #--
- # this behavior is no longer required. If you wish to change it
- # go ahead, just make sure the specs pass
def initialize(buffer = nil)
- @buf = buffer ? Bytes.force_binary_encoding(buffer) :
Bytes.empty_byte_buffer
+ @buf = buffer ? Bytes.force_binary_encoding(buffer.dup) :
Bytes.empty_byte_buffer
Review Comment:
`MemoryBufferTransport` accepts a String, and the previous implementation
did not coerce String-like objects: `Bytes.force_binary_encoding` immediately
calls String APIs. All supported String inputs implement `dup`; adding coercion
or validation would change the constructor contract, so I’m leaving this
unchanged.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]