[
https://issues.apache.org/jira/browse/THRIFT-735?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12845733#action_12845733
]
David Reiss commented on THRIFT-735:
------------------------------------
> If this formulation is correct, then I'd suggest that the way to achieve this
> is to let the field's required or optional modifier specify the "zero"
> possibility (through unset fields) and required specify the "exactly one". I
> think this will most support users' expectations.
> Again, the onus is on the schema designer to specify, through
> optional/required, whether they can tolerate missing values in given fields.
I general, I don't like the idea of showing a field as having been absent when
it was present but contained and unexpected value. How does that work with
containers? I think the decision of whether a field is set of unset has to be
completely independent of any attempts to interpret it.
The idea of an annotation on enum and union types that indicates whether an
unexpected value should trigger a validation error is appealing to me.
> 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.