THRIFT-1527. java: Generated implementation of tupleReadStruct in unions return null when the setfield is unrecognized
Unrecognized fields will now result in a TProtocolException when reading with the TupleProtocol.
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1295997 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 3f83222..6ef3838 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -353,6 +353,7 @@
"import org.apache.thrift.scheme.StandardScheme;\n\n" +
"import org.apache.thrift.scheme.TupleScheme;\n" +
"import org.apache.thrift.protocol.TTupleProtocol;\n" +
+ "import org.apache.thrift.protocol.TProtocolException;\n" +
"import org.apache.thrift.EncodingUtils;\n" +
"import java.util.List;\n" +
"import java.util.ArrayList;\n" +
@@ -1082,7 +1083,7 @@
indent_down();
indent(out) << "} else {" << endl;
indent_up();
- indent(out) << "return null;" << endl;
+ indent(out) << "throw new TProtocolException(\"Couldn't find a field with field id \" + fieldID);" << endl;
indent_down();
indent(out) << "}" << endl;
indent_down();