[
https://issues.apache.org/jira/browse/THRIFT-1528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13220731#comment-13220731
]
Stefan Gmeiner commented on THRIFT-1528:
----------------------------------------
I found the following statement in [Thrift Missing
Guide|http://diwakergupta.github.com/thrift-missing-guide/]:
{quote}
Changing a default value is generally OK, as long as you remember that default
values are never sent over the wire. Thus, if a program receives a message in
which a particular field isn’t set, the program will see the default value as
it was defined in that program’s version of the protocol. It will NOT see the
default value that was defined in the sender’s code.
{quote}
Example:
If you update a server with a changed default value you will get different
behavior depending if you use Java or Python as old client. If the old Java
client talks to the new server (without using the default field) the server
will see the new default value whereas the the python client will sent the old
default value and thus the server will get the old default value.
I'm not sure which one should be preferred but I think it should not depending
on the client language used. I don't see an reason why some language should
behave different than the static ones (to ensure binary compatibility the
thrift compiler could provide a language option to control the generation of
the code).
> Iconsistency in optional fields between Java/C# and python
> ----------------------------------------------------------
>
> Key: THRIFT-1528
> URL: https://issues.apache.org/jira/browse/THRIFT-1528
> Project: Thrift
> Issue Type: Bug
> Components: Python - Compiler
> Affects Versions: 0.8
> Reporter: Stefan Gmeiner
> Priority: Minor
>
> If a struct contains optional fields with default values the generated python
> code serialize differently than Java or C# code.
> In Java or C# optional fields are only serialized if a field was set by the
> client. If not the field is omited during serialization. This is possible
> because C#/Java maintains for each field a 'isset'-boolean which records if a
> field was set or not.
> However the generated python code does not have such a 'isset'-structure. It
> writes every field which is not equal None. As the constructor initialize the
> optional fields with their default value, these fields are written whether
> they are set or not.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira