You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by br...@apache.org on 2012/03/02 00:43:54 UTC
svn commit: r1295997 -
/thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc
Author: bryanduxbury
Date: Thu Mar 1 23:43:54 2012
New Revision: 1295997
URL: http://svn.apache.org/viewvc?rev=1295997&view=rev
Log:
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.
Modified:
thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc
Modified: thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc
URL: http://svn.apache.org/viewvc/thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc?rev=1295997&r1=1295996&r2=1295997&view=diff
==============================================================================
--- thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc (original)
+++ thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc Thu Mar 1 23:43:54 2012
@@ -353,6 +353,7 @@ string t_java_generator::java_type_impor
"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 @@ void t_java_generator::generate_tuple_sc
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();