[
https://issues.apache.org/jira/browse/THRIFT-735?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12845707#action_12845707
]
David Reiss commented on THRIFT-735:
------------------------------------
> If a struct has a required field of type enum and a value goes away, again,
> it will be treated as an unset field. If this field was required, then it
> would not pass deserialization validation.
Yeah, I don't think we should do that. It means that once you use some type as
a required field, you've limited the flexiblity of that type. I think that
adding a required field should only limit the flexibility of the type that has
the required field.
> If you have a struct with a required field that's a union, you can add or
> rename fields with impunity. If you remove a union field, and you can't get a
> valid value in that struct field anymore
Ah, but you're showing your bias toward offline processing, where it's always
the old code during the writing and the new code doing the reading. My bias is
toward RPC, where clients and servers both read and both write, so upgrades can
go in either direction. Adding a field on the write side is the same as
removing a field on the read side.
> Required field checking is broken when the field type is a Union struct
> -----------------------------------------------------------------------
>
> Key: THRIFT-735
> URL: https://issues.apache.org/jira/browse/THRIFT-735
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Java), Library (Java)
> Affects Versions: 0.2
> Reporter: Bryan Duxbury
> Assignee: Bryan Duxbury
> Fix For: 0.3
>
> Attachments: thrift-735.patch
>
>
> The validate() method on generated structs verifies that required fields are
> set after validation. However, if the type of the field is a Union struct,
> then just checking that the field isn't null is not a valid check. The value
> may be a non-null union, but have an unset field. (We encountered this when
> deserializing a type that had a union for a field, and the union's set value
> was an enum value that had been removed from the definition, making it a
> skip.)
> In order to perform the correct validation, if the value is a Union, then we
> must also check that the set field and value are non-null.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.