kpumuk commented on code in PR #3703:
URL: https://github.com/apache/thrift/pull/3703#discussion_r3740800640


##########
lib/rb/lib/thrift/protocol/compact_protocol.rb:
##########
@@ -389,44 +437,51 @@ def to_s
     # the wire differ only by the type indicator.
     #
     def write_collection_begin(elem_type, size)
+      size = validate_size(size)
+      compact_type = CompactTypes.get_compact_type(elem_type)
       if size <= 14
-        write_byte(size << 4 | CompactTypes.get_compact_type(elem_type))
+        write_byte_direct(size << 4 | compact_type)
       else
-        write_byte(0xf0 | CompactTypes.get_compact_type(elem_type))
+        write_byte_direct(0xf0 | compact_type)
         write_varint32(size)
       end
     end
 
+    def write_byte_direct(byte)
+      @trans.write([byte].pack('C'))
+    end

Review Comment:
   Ruby’s `Array#pack('C')` intentionally retains the low eight bits rather 
than rejecting negative integers. This is documented behavior and was verified 
by the pure-Ruby suite on Ruby 2.7.8: `PROTOCOL_ID == -126` encodes as `0x82`, 
and `write_byte(-128)` encodes as `0x80`. The new signed-boundary spec directly 
covers this path, so no change is required.



-- 
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]

Reply via email to