Dmytro Shteflyuk created THRIFT-6118:
----------------------------------------
Summary: Ruby ProtocolDecorator should forward message begin
arguments
Key: THRIFT-6118
URL: https://issues.apache.org/jira/browse/THRIFT-6118
Project: Thrift
Issue Type: Bug
Components: Ruby - Library
Reporter: Dmytro Shteflyuk
Assignee: Dmytro Shteflyuk
h3. Problem
{{Thrift::ProtocolDecorator#write_message_begin}} accepts the message name,
message type, and sequence ID, but calls the decorated protocol's
{{write_message_begin}} method without any arguments.
The decorated protocol requires all three values, so a concrete decorator
relying on the module's default implementation raises {{ArgumentError}} instead
of beginning the message. {{MultiplexedProtocol}} overrides this method, which
prevents the defect from appearing in its usual code path, but other or
third-party decorators using the shared implementation remain affected.
h3. Client impact
A Ruby client using such a protocol decorator cannot serialize an outbound
message. The failure occurs before the message body is written, so the RPC
cannot be sent through that decorator.
h3. Reproduction
{code:ruby}
require "thrift"
protocol = Object.new
def protocol.write_message_begin(name, type, seqid)
end
decorator_class = Class.new(Thrift::BaseProtocol) do
include Thrift::ProtocolDecorator
end
decorator = decorator_class.new(protocol)
decorator.write_message_begin("method", Thrift::MessageTypes::CALL, 42)
{code}
Current result:
{noformat}
ArgumentError: wrong number of arguments (given 0, expected 3)
{noformat}
The exception originates from {{ProtocolDecorator#write_message_begin}}
invoking the decorated method with zero arguments.
h3. Expected behavior
{{ProtocolDecorator#write_message_begin}} should forward the message name,
message type, and sequence ID unchanged to the decorated protocol. A focused
contract test should verify the exact positional values.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)