Skip to content

THRIFT-6104: Accept Ruby Set subclasses in native struct writing#3645

Merged
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-set-subclasses
Jul 20, 2026
Merged

THRIFT-6104: Accept Ruby Set subclasses in native struct writing#3645
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-set-subclasses

Conversation

@kpumuk

@kpumuk kpumuk commented Jul 19, 2026

Copy link
Copy Markdown
Member

The native struct writer checked for the exact Set class when serializing Thrift set fields. A Set subclass was therefore routed to Hash handling and rejected, while the pure-Ruby writer accepted and serialized the same value.

The native writer now honors the public Set contract, allowing subclasses to serialize the same elements as an equivalent Set.

  • Did you create an Apache Jira ticket? THRIFT-6104
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

Client: rb

Co-Authored-By: OpenAI Codex (GPT-5.4) <codex@openai.com>
Copilot AI review requested due to automatic review settings July 19, 2026 18:58
@mergeable mergeable Bot added the ruby Pull requests that update Ruby code label Jul 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns the Ruby native struct writer’s handling of Thrift set fields with Ruby’s Set contract by accepting Set subclasses (previously rejected by a strict class check). This brings behavior in line with the pure-Ruby writer and avoids incorrectly routing Set subclasses through Hash handling.

Changes:

  • Update native TTYPE_SET serialization to treat any Set subclass as a Set via rb_obj_is_kind_of.
  • Add an RSpec example ensuring a Set subclass serializes identically to an equivalent Set.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/rb/spec/struct_spec.rb Adds a regression spec asserting Set subclasses serialize like Set.
lib/rb/ext/struct.c Changes native set-container detection from exact-class match to kind_of?(Set) semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kpumuk
kpumuk merged commit 9e96ff4 into apache:master Jul 20, 2026
94 of 95 checks passed
@kpumuk
kpumuk deleted the rb-set-subclasses branch July 20, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Pull requests that update Ruby code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants