summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Reiss <dreiss@apache.org>2009-08-27 20:27:09 +0000
committerDavid Reiss <dreiss@apache.org>2009-08-27 20:27:09 +0000
commitaf81de0123c8d9920a25a27d28da66f9d00748cc (patch)
treea85adc2cfe4a3e5ae040f4b3eecb64e92f8013b8
parent2c8cd944e50d4d69f00fde70ecee9c75ab924e2b (diff)
downloadthrift-af81de0123c8d9920a25a27d28da66f9d00748cc.tar.gz
Revert r806014 "THRIFT-562. java: Java is inconsistent ..."
- It changed the semantics of default-presence fields. - It messed up calls that accept exceptions. - Full details on issue. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@808609 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--compiler/cpp/src/generate/t_java_generator.cc6
-rw-r--r--lib/java/test/org/apache/thrift/test/Fixtures.java12
-rwxr-xr-xlib/java/test/org/apache/thrift/test/TCompactProtocolTest.java6
3 files changed, 5 insertions, 19 deletions
diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc
index 0a6ebead5..32e9b54d7 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -1065,7 +1065,7 @@ void t_java_generator::generate_java_struct_reader(ofstream& out,
if (!bean_style_){
out << endl << indent() << "// check for required fields of primitive type, which can't be checked in the validate method" << endl;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- if ((*f_iter)->get_req() != t_field::T_OPTIONAL && !type_can_be_null((*f_iter)->get_type())) {
+ if ((*f_iter)->get_req() == t_field::T_REQUIRED && !type_can_be_null((*f_iter)->get_type())) {
out <<
indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl <<
indent() << " throw new TProtocolException(\"Required field '" << (*f_iter)->get_name() << "' was not found in serialized data! Struct: \" + toString());" << endl <<
@@ -1095,7 +1095,7 @@ void t_java_generator::generate_java_validator(ofstream& out,
out << indent() << "// check for required fields" << endl;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- if ((*f_iter)->get_req() != t_field::T_OPTIONAL) {
+ if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
if (bean_style_) {
out <<
indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl <<
@@ -1107,7 +1107,7 @@ void t_java_generator::generate_java_validator(ofstream& out,
indent(out) << " throw new TProtocolException(\"Required field '" << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << endl;
indent(out) << "}" << endl;
} else {
- indent(out) << "// '" << (*f_iter)->get_name() << "' is only checked in read() because it's a primitive and you chose the non-beans generator." << endl;
+ indent(out) << "// alas, we cannot check '" << (*f_iter)->get_name() << "' because it's a primitive and you chose the non-beans generator." << endl;
}
}
}
diff --git a/lib/java/test/org/apache/thrift/test/Fixtures.java b/lib/java/test/org/apache/thrift/test/Fixtures.java
index 7ef91ef21..ea250dd98 100644
--- a/lib/java/test/org/apache/thrift/test/Fixtures.java
+++ b/lib/java/test/org/apache/thrift/test/Fixtures.java
@@ -112,17 +112,7 @@ public class Fixtures {
// superhuge compact proto test struct
compactProtoTestStruct = new CompactProtoTestStruct(thrift.test.Constants.COMPACT_TEST);
- compactProtoTestStruct.a_binary = new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8};
- compactProtoTestStruct.binary_list = Arrays.asList(new byte[]{(byte) 0, (byte) 1}, new byte[]{(byte) 2, (byte) 3});
- compactProtoTestStruct.binary_set = new HashSet<byte[]>(compactProtoTestStruct.binary_list);
- compactProtoTestStruct.binary_byte_map = new HashMap<byte[], Byte>() {{
- put(new byte[]{(byte) 0, (byte) 1}, (byte) 100);
- put(new byte[]{(byte) 2, (byte) 3}, (byte) 101);
- }};
- compactProtoTestStruct.byte_binary_map = new HashMap<Byte, byte[]>() {{
- put((byte) 100, new byte[]{(byte) 0, (byte) 1});
- put((byte) 101, new byte[]{(byte) 2, (byte) 3});
- }};
+ compactProtoTestStruct.a_binary = new byte[]{0,1,2,3,4,5,6,7,8};
} catch (Exception e) {
throw new RuntimeException(e);
}
diff --git a/lib/java/test/org/apache/thrift/test/TCompactProtocolTest.java b/lib/java/test/org/apache/thrift/test/TCompactProtocolTest.java
index 99173401e..5d1c3cba1 100755
--- a/lib/java/test/org/apache/thrift/test/TCompactProtocolTest.java
+++ b/lib/java/test/org/apache/thrift/test/TCompactProtocolTest.java
@@ -324,11 +324,7 @@ public class TCompactProtocolTest {
T objRead = klass.newInstance();
objRead.read(proto);
- // TODO equals is broken when List<array> is involved, since AbstractList.equals(Object o)
- // calls o.equals, but for arrays that is just == which will never work when you are
- // comparing pre- and post- serialized versions. You need to use Arrays.equals instead.
- // So, here I have special-cased CPTS to avoid failing the test b/c of this bug.
- if (!obj.equals(objRead) && klass != CompactProtoTestStruct.class) {
+ if (!obj.equals(objRead)) {
System.out.println("Expected: " + obj.toString());
System.out.println("Actual: " + objRead.toString());
// System.out.println(buf.inspect());