[ 
https://issues.apache.org/jira/browse/THRIFT-5264?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jens Geyer updated THRIFT-5264:
-------------------------------
    Component/s: Compiler (General)

> Argument requiredness and field requiredness
> --------------------------------------------
>
>                 Key: THRIFT-5264
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5264
>             Project: Thrift
>          Issue Type: Question
>          Components: Compiler (General)
>    Affects Versions: 0.13.0
>            Reporter: Yufan Gong
>            Assignee: Jens Geyer
>            Priority: Major
>
> 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)

Reply via email to