diff options
author | Jake Farrell <jfarrell@apache.org> | 2012-01-27 04:48:26 +0000 |
---|---|---|
committer | Jake Farrell <jfarrell@apache.org> | 2012-01-27 04:48:26 +0000 |
commit | f9f01fa1e054ff28d7b8023eeb53cd5ba0ed6b1c (patch) | |
tree | 7cd1d0604894e57fec7a1468c9ddf9619d71dd9a /test/OptionalRequiredTest.thrift | |
parent | 6ce2704a14bb109d2d9e29d1b77974f57b2e8636 (diff) | |
download | thrift-f9f01fa1e054ff28d7b8023eeb53cd5ba0ed6b1c.tar.gz |
THRIFT-1394:Treatment of optional fields is not consistent between C++ and Java
Client: cpp
Patch: Diwaker Gupta
In CPP, all optional fields are guarded by the isset helper struct. On Java, however, the generated code takes advantage of nullable types: for containers, structs, exceptions, enums, and, notably, strings, the generator elides explicit use of an "isset" bit vector and instead emits checks of the form "field null". This leads to varying behavior between the two languages: an optional string field with a default value will have {{isset[fieldid]}} false on C, but the equivalent test in Java will be true.
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1236529 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/OptionalRequiredTest.thrift')
-rw-r--r-- | test/OptionalRequiredTest.thrift | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/OptionalRequiredTest.thrift b/test/OptionalRequiredTest.thrift index 8108a7f7b..dcdd0f2cc 100644 --- a/test/OptionalRequiredTest.thrift +++ b/test/OptionalRequiredTest.thrift @@ -49,6 +49,11 @@ struct Tricky3 { 1: required i16 im_required; } +struct OptionalDefault { + 1: optional i16 opt_int = 1234; + 2: optional string opt_str = "default"; +} + struct Complex { 1: i16 cp_default; 2: required i16 cp_required; |