From: Bryan Duxbury Date: Tue, 14 Jul 2009 01:42:09 +0000 (+0000) Subject: THRIFT-543. java: Generate normal style java files should respect the "optional"... X-Git-Tag: 0.2.0~76 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=8f5827358be83cc9dd8ddef04dc79ef2c2ac2775;p=common%2Fthrift.git THRIFT-543. java: Generate normal style java files should respect the "optional" keyword when serializing As the summary suggests, this patch causes "optional" fields to be skipped if they are unset, even if they are primitives. As this patch is for the non-beans style generator, the user is expected to maintain the set/unset status themselves. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@793778 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc index 2d1381c4..e0d1c0cc 100644 --- a/compiler/cpp/src/generate/t_java_generator.cc +++ b/compiler/cpp/src/generate/t_java_generator.cc @@ -1096,7 +1096,7 @@ void t_java_generator::generate_java_struct_writer(ofstream& out, indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << endl; indent_up(); } - bool optional = bean_style_ && (*f_iter)->get_req() == t_field::T_OPTIONAL; + bool optional = (*f_iter)->get_req() == t_field::T_OPTIONAL; if (optional) { indent(out) << "if (" << generate_isset_check((*f_iter)) << ") {" << endl; indent_up();