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 2011/09/01 20:54:07 UTC
svn commit: r1164202 - in /thrift/trunk:
compiler/cpp/src/generate/t_java_generator.cc
lib/java/test/org/apache/thrift/TestTUnion.java
Author: bryanduxbury
Date: Thu Sep 1 18:54:07 2011
New Revision: 1164202
URL: http://svn.apache.org/viewvc?rev=1164202&view=rev
Log:
THRIFT-1319. java: Mismatch between how a union reads and writes a container
This patch fixes the problem in the java generator (and removes an unnecessary comment). It also amends TestTUnion to catch this.
Patch: Armaan Sarkar
Modified:
thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc
thrift/trunk/lib/java/test/org/apache/thrift/TestTUnion.java
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=1164202&r1=1164201&r2=1164202&view=diff
==============================================================================
--- thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc (original)
+++ thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc Thu Sep 1 18:54:07 2011
@@ -773,10 +773,6 @@ void t_java_generator::generate_java_uni
f_struct << endl;
- // generate_java_struct_standard_scheme(f_struct, tstruct);
-
- f_struct << endl;
-
scope_down(f_struct);
f_struct.close();
@@ -1028,7 +1024,7 @@ void t_java_generator::generate_write_va
indent_up();
indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name()
<< " = (" << type_name(field->get_type(), true, false) << ")value_;" << endl;
- generate_serialize_field(out, field, "", false);
+ generate_serialize_field(out, field, "");
indent(out) << "return;" << endl;
indent_down();
}
Modified: thrift/trunk/lib/java/test/org/apache/thrift/TestTUnion.java
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/java/test/org/apache/thrift/TestTUnion.java?rev=1164202&r1=1164201&r2=1164202&view=diff
==============================================================================
--- thrift/trunk/lib/java/test/org/apache/thrift/TestTUnion.java (original)
+++ thrift/trunk/lib/java/test/org/apache/thrift/TestTUnion.java Thu Sep 1 18:54:07 2011
@@ -24,6 +24,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -152,6 +153,7 @@ public class TestTUnion extends TestCase
public void testSerialization() throws Exception {
TestUnion union = new TestUnion(TestUnion._Fields.I32_FIELD, 25);
+ union.setI32_set(Collections.singleton(42));
TMemoryBuffer buf = new TMemoryBuffer(0);
TProtocol proto = new TBinaryProtocol(buf);