You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ns...@apache.org on 2015/11/10 16:34:22 UTC

[2/3] thrift git commit: THRIFT-2974 fix optional writeToParcel Client: Java Patch: Max Spencer

THRIFT-2974 fix optional writeToParcel
Client: Java
Patch: Max Spencer

This closes #687


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/c04fb006
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/c04fb006
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/c04fb006

Branch: refs/heads/master
Commit: c04fb0069e814d761248f26a24142730d5e80501
Parents: 317d515
Author: Max Spencer <mr...@googlemail.com>
Authored: Tue Nov 10 11:34:19 2015 +0000
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Wed Nov 11 00:32:55 2015 +0900

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_java_generator.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/c04fb006/compiler/cpp/src/generate/t_java_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc
index 9da52d1..733852f 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -1634,7 +1634,7 @@ void t_java_generator::generate_java_struct_parcelable(ofstream& out, t_struct*
     } else if (type_name(t) == "float") {
       indent(out) << "out.writeFloat(" << name << ");" << endl;
     } else if (t->is_enum()) {
-      indent(out) << "out.writeInt(" << name << ".getValue());" << endl;
+      indent(out) << "out.writeInt(" << name << " != null ? " << name << ".getValue() : -1);" << endl;
     } else if (t->is_list()) {
       if (((t_list*)t)->get_elem_type()->get_true_type()->is_struct()) {
         indent(out) << "out.writeTypedList(" << name << ");" << endl;