[ https://issues.apache.org/jira/browse/THRIFT-735?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12893352#action_12893352 ]
Bryan Duxbury commented on THRIFT-735: -------------------------------------- bq. An unknown (to server) enum value as a required method argument results in a TApplicationException (like "Required field 'value' is unset! Struct:fromEnumRequired_args(value:null)") on the client Right. So what I propose is that when we are checking if a required field is set, if it's a union field, we also check if the _union itself_ is set. This would make it behave similarly to enum values. Thoughts? > 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.4 > > Attachments: thrift-735-v2.patch, thrift-735.patch, > unknown_enum_tests.zip > > > 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.