[
https://issues.apache.org/jira/browse/THRIFT-5264?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jens Geyer resolved THRIFT-5264.
--------------------------------
Fix Version/s: 0.14.0
Assignee: Jens Geyer
Resolution: Done
1. Arg requiredness is unsupported. You are free to send pull requests, Therese
is some open ticket IIRC.
2. The intended behaviiour of field requirednesses (required, optional and
default) is explained at many other places already. Anything else can be
considered incorrect and is worth a pull request as well.
> Argument requiredness and field requiredness
> --------------------------------------------
>
> Key: THRIFT-5264
> URL: https://issues.apache.org/jira/browse/THRIFT-5264
> Project: Thrift
> Issue Type: Question
> Affects Versions: 0.13.0
> Reporter: Yufan Gong
> Assignee: Jens Geyer
> Priority: Major
> Fix For: 0.14.0
>
>
> I have two questions regarding the requiredness in the generated code.
> 1. Argument requiredness is ignored
> When defining a method
> {code:java}
> string echo(1: optional string msg){code}
> got
> {code:java}
> optional keyword is ignored in argument lists.
> {code}
> We would like to ask about the future plan of supporting argument
> requiredness.
> Full context: our team maintains a Thrift code generator built upon Apache
> Thrift, [Scrooge|https://github.com/twitter/scrooge], which now respects the
> optional keyword in the argument list and generates an Optional argument. We
> want to align with the libthrift's future plan to reduce potential
> incompatible issues.
> 2. Field requiredness is unmatched across languages
> We noticed that Apache Thrift generated different behavioral code for
> different languages.
> Taking this as an example
> {code:java}
> struct TestRequiredness {
> 1: i32 A
> 2: required i32 B
> 3: optional i32 C
> }{code}
> Generated Java code has 3 different read/write requiredness combinations for
> all three, and they are what we expected. OptInReqOut: optional write and
> required Read, Required: required on both read and write, Optional: optional
> on both read and write.
> However, the generated Python code treats all three the same: Optional read
> and write. (there is a validate method checking for B, but doesn't seem to be
> forced on either read or write path).
> After a quick skim, it seems the generated PHP code has the same behavior as
> Python.
> Assuming python client talking to java server with required fields set, this
> could cause the TProtocolExceptions being propagated to the server, while
> python client should catch them earlier.
> Thanks!
--
This message was sent by Atlassian Jira
(v8.3.4#803005)