You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Vitali Lovich (JIRA)" <ji...@apache.org> on 2013/06/21 02:45:20 UTC
[jira] [Created] (THRIFT-2055) Inconsistent serialization of unset
variables between primitives & objects
Vitali Lovich created THRIFT-2055:
-------------------------------------
Summary: Inconsistent serialization of unset variables between primitives & objects
Key: THRIFT-2055
URL: https://issues.apache.org/jira/browse/THRIFT-2055
Project: Thrift
Issue Type: Bug
Components: Java - Compiler
Affects Versions: 0.9
Reporter: Vitali Lovich
A non-optional field will be serialized even if not set if it is a number/boolean whereas not for objects. For example, round-tripping:
{code}
struct Foo {
int x;
string y;
}
{code}
Using JSON notation for convenience
Input: { "x": 5 }
In-memory object: isSetX() returns true, isSetY() returns false
Output: { "x": 5 }
Input: { "y": "foo" }
In-memory object: isSetX() returns false, isSetY() returns true
Output: { "x": 0, "y": "foo" }
It should be consistent. My gut is that the latter case is wrong and unset primitives should be omitted from serialization even if not optional. My guess is that fields marked with required should always output them regardless of isSet, but not sure.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira