[ 
https://issues.apache.org/jira/browse/THRIFT-6119?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dmytro Shteflyuk resolved THRIFT-6119.
--------------------------------------
    Fix Version/s: 0.25.0
       Resolution: Fixed

> Ruby MultiplexedProtocol diagnostics should preserve the service name
> ---------------------------------------------------------------------
>
>                 Key: THRIFT-6119
>                 URL: https://issues.apache.org/jira/browse/THRIFT-6119
>             Project: Thrift
>          Issue Type: Bug
>          Components: Ruby - Library
>            Reporter: Dmytro Shteflyuk
>            Assignee: Dmytro Shteflyuk
>            Priority: Major
>             Fix For: 0.25.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> h3. Problem
> {{Thrift::MultiplexedProtocol#to_s}} contains an assignment while formatting 
> its diagnostic string:
> {code:ruby}
> "multiplexed(#{@[email protected]_s})"
> {code}
> Calling {{to_s}} therefore replaces the configured multiplexed service name 
> with the underlying protocol's diagnostic label. For example, a protocol 
> configured for {{Calculator}} is changed to {{binary(memory)}}. The next call 
> or oneway message is then written with the wrong service prefix.
> h3. Client impact
> Logging, string interpolation, or error reporting that formats a multiplexed 
> protocol can change later RPC behavior. Requests that should be addressed to 
> a configured service such as {{Calculator:add}} are instead sent as 
> {{binary(memory):add}}, so the server cannot route them to the intended 
> multiplexed service.
> The effect persists for the lifetime of that protocol instance because the 
> original service name has been overwritten.
> h3. Reproduction
> {code:ruby}
> require "thrift"
> transport = Thrift::MemoryBufferTransport.new
> protocol = Thrift::MultiplexedProtocol.new(
>   Thrift::BinaryProtocol.new(transport),
>   "Calculator"
> )
> diagnostic = protocol.to_s
> protocol.write_message_begin("add", Thrift::MessageTypes::CALL, 7)
> name, type, seqid = Thrift::BinaryProtocol.new(transport).read_message_begin
> puts "to_s=#{diagnostic.inspect}"
> puts "wire_name=#{name.inspect} type=#{type} seqid=#{seqid}"
> {code}
> Current output:
> {noformat}
> to_s="multiplexed(binary(memory))"
> wire_name="binary(memory):add" type=1 seqid=7
> {noformat}
> The expected wire name is {{Calculator:add}}.
> h3. Expected behavior
> {{MultiplexedProtocol#to_s}} should be side-effect-free. Repeated diagnostic 
> formatting must leave the configured service name unchanged, and later 
> messages must continue using the original service prefix on the wire.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to