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

Dmytro Shteflyuk updated THRIFT-6104:
-------------------------------------
    Component/s: Ruby - Library

> Ruby native struct writing should accept Set subclasses
> -------------------------------------------------------
>
>                 Key: THRIFT-6104
>                 URL: https://issues.apache.org/jira/browse/THRIFT-6104
>             Project: Thrift
>          Issue Type: Bug
>          Components: Ruby - Library
>            Reporter: Dmytro Shteflyuk
>            Assignee: Dmytro Shteflyuk
>            Priority: Major
>
> h3. Problem
> The native struct writer handles a Thrift {{set}} field as a Ruby {{Set}} 
> only when the value has the exact {{Set}} class.
> A subclass of {{Set}} is therefore rejected by the native extension and falls 
> through to the Hash handling path. The pure-Ruby writer accepts the subclass 
> through the normal {{Set}} contract and serializes its elements.
> h3. Client impact
> Ruby clients can use a {{Set}} subclass for a generated struct field declared 
> as a Thrift {{set}}, yet receive different behavior depending on whether 
> {{thrift_native}} is loaded.
> The same value serializes in pure-Ruby mode but raises a type error in native 
> mode, even though it has the public {{Set}} behavior expected by the 
> generated field.
> h3. Reproduction
> Given a generated struct with a {{set<i16>}} field:
> {code:ruby}
> class TaggedSet < Set
> end
> record = MyGeneratedStruct.new(
>   values: TaggedSet.new([5, 17, 239])
> )
> Thrift::Serializer.new(Thrift::BinaryProtocolFactory.new).serialize(record)
> {code}
> With the native extension loaded, serialization rejects {{TaggedSet}} as 
> though it were not a {{Set}}. Without the native extension, it serializes the 
> same elements.
> h3. Expected behavior
> Native struct writing should honor the public {{Set}} contract and accept 
> subclasses of {{Set}}. A {{Set}} subclass should serialize the same elements 
> as an equivalent {{Set}}.



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

Reply via email to