Merge pull request #1870 from dbcfd/thrift-4953
THRIFT-4953: Missing Field Identifiers
diff --git a/compiler/cpp/src/thrift/generate/t_java_generator.cc b/compiler/cpp/src/thrift/generate/t_java_generator.cc
index 2fb1f1a..7254e12 100644
--- a/compiler/cpp/src/thrift/generate/t_java_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_java_generator.cc
@@ -731,7 +731,11 @@
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
switch (tbase) {
case t_base_type::TYPE_STRING:
- render << '"' << get_escaped_string(value) << '"';
+ if (((t_base_type*)type)->is_binary()) {
+ render << "java.nio.ByteBuffer.wrap(\"" << get_escaped_string(value) << "\".getBytes())";
+ } else {
+ render << '"' << get_escaped_string(value) << '"';
+ }
break;
case t_base_type::TYPE_BOOL:
render << ((value->get_integer() > 0) ? "true" : "false");
diff --git a/doc/committers.md b/doc/committers.md
index dcdd7b7..2326711 100644
--- a/doc/committers.md
+++ b/doc/committers.md
@@ -28,17 +28,16 @@
1. The commit message should be in the format:
- THRIFT-###:<Jira description>
+ THRIFT-####:<Jira description>
Client: <component>
Patch: <Name of person contributing the patch>
Description of what was fixed or addressed.
- <%
- if this is a github pull request then add below comment
- to automaticaly close GitHub request.
- %>
- This closes #XX
+ If this is a github pull request then add below comment to automaticaly close GitHub request,
+ where #NNNN is the PR number:
+
+ This closes #NNNN
1. Double check the patch committed and that nothing was missed then push the patch
diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_server_socket.c b/lib/c_glib/src/thrift/c_glib/transport/thrift_server_socket.c
index 1646374..21ce1ee 100644
--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_server_socket.c
+++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_server_socket.c
@@ -85,7 +85,7 @@
{
g_set_error (error, THRIFT_SERVER_SOCKET_ERROR,
THRIFT_SERVER_SOCKET_ERROR_BIND,
- "failed to bind to path %s",
+ "failed to bind to path %s: - %s",
tsocket->path, strerror(errno));
return FALSE;
}
@@ -115,7 +115,7 @@
{
g_set_error (error, THRIFT_SERVER_SOCKET_ERROR,
THRIFT_SERVER_SOCKET_ERROR_BIND,
- "failed to bind to path %s",
+ "failed to bind to path %s: - %s",
tsocket->path, strerror(errno));
return FALSE;
}
diff --git a/lib/cpp/src/thrift/concurrency/TimerManager.cpp b/lib/cpp/src/thrift/concurrency/TimerManager.cpp
index 003f564..703c19e 100644
--- a/lib/cpp/src/thrift/concurrency/TimerManager.cpp
+++ b/lib/cpp/src/thrift/concurrency/TimerManager.cpp
@@ -132,7 +132,7 @@
Synchronized s(manager_->monitor_);
if (manager_->state_ == TimerManager::STOPPING) {
manager_->state_ = TimerManager::STOPPED;
- manager_->monitor_.notify();
+ manager_->monitor_.notifyAll();
}
}
return;
diff --git a/lib/csharp/src/Transport/TSocketVersionizer.cs b/lib/csharp/src/Transport/TSocketVersionizer.cs
index bf4c0e4..8c2f8e9 100644
--- a/lib/csharp/src/Transport/TSocketVersionizer.cs
+++ b/lib/csharp/src/Transport/TSocketVersionizer.cs
@@ -41,7 +41,7 @@
internal static class TSocketVersionizer
{
/// <summary>
- /// Creates a TcpClient according to the capabilitites of the used framework
+ /// Creates a TcpClient according to the capabilities of the used framework.
/// </summary>
internal static TcpClient CreateTcpClient()
{
@@ -58,7 +58,7 @@
}
/// <summary>
- /// Creates a TcpListener according to the capabilitites of the used framework.
+ /// Creates a TcpListener according to the capabilities of the used framework.
/// </summary>
internal static TcpListener CreateTcpListener(Int32 port)
{
diff --git a/lib/java/gradle/generateTestThrift.gradle b/lib/java/gradle/generateTestThrift.gradle
index 2b53739..121bf53 100644
--- a/lib/java/gradle/generateTestThrift.gradle
+++ b/lib/java/gradle/generateTestThrift.gradle
@@ -80,6 +80,7 @@
thriftCompile(it, 'ManyOptionals.thrift')
thriftCompile(it, 'JavaDeepCopyTest.thrift')
thriftCompile(it, 'EnumContainersTest.thrift')
+ thriftCompile(it, 'JavaBinaryDefault.thrift')
}
task generateBeanJava(group: 'Build') {
diff --git a/lib/java/test/org/apache/thrift/protocol/TestTSimpleJSONProtocol.java b/lib/java/test/org/apache/thrift/protocol/TestTSimpleJSONProtocol.java
index 9d125b1..171a487 100644
--- a/lib/java/test/org/apache/thrift/protocol/TestTSimpleJSONProtocol.java
+++ b/lib/java/test/org/apache/thrift/protocol/TestTSimpleJSONProtocol.java
@@ -80,7 +80,7 @@
struct.unsetDouble_byte_map();
struct.unsetString_byte_map();
struct.write(proto);
- assertEquals("{\"a_byte\":127,\"a_i16\":32000,\"a_i32\":1000000000,\"a_i64\":1099511627775,\"a_double\":5.6789,\"a_string\":\"my string\",\"a_binary\":\"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\",\"true_field\":1,\"false_field\":0,\"empty_struct_field\":{},\"byte_list\":[-127,-1,0,1,127],\"i16_list\":[-1,0,1,32767],\"i32_list\":[-1,0,255,65535,16777215,2147483647],\"i64_list\":[-1,0,255,65535,16777215,4294967295,1099511627775,281474976710655,72057594037927935,9223372036854775807],\"double_list\":[0.1,0.2,0.3],\"string_list\":[\"first\",\"second\",\"third\"],\"boolean_list\":[1,1,1,0,0,0],\"struct_list\":[{},{}],\"i32_set\":[1,2,3],\"boolean_set\":[0,1],\"struct_set\":[{}],\"byte_byte_map\":{\"1\":2},\"boolean_byte_map\":{\"0\":0,\"1\":1},\"byte_i16_map\":{\"1\":1,\"2\":-1,\"3\":32767},\"byte_i32_map\":{\"1\":1,\"2\":-1,\"3\":2147483647},\"byte_i64_map\":{\"1\":1,\"2\":-1,\"3\":9223372036854775807},\"byte_double_map\":{\"1\":0.1,\"2\":-0.1,\"3\":1000000.1},\"byte_string_map\":{\"1\":\"\",\"2\":\"blah\",\"3\":\"loooooooooooooong string\"},\"byte_boolean_map\":{\"1\":1,\"2\":0},\"byte_map_map\":{\"0\":{},\"1\":{\"1\":1},\"2\":{\"1\":1,\"2\":2}},\"byte_set_map\":{\"0\":[],\"1\":[1],\"2\":[1,2]},\"byte_list_map\":{\"0\":[],\"1\":[1],\"2\":[1,2]}}", bufToString());
+ assertEquals("{\"a_byte\":127,\"a_i16\":32000,\"a_i32\":1000000000,\"a_i64\":1099511627775,\"a_double\":5.6789,\"a_string\":\"my string\",\"a_binary\":\"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\",\"true_field\":1,\"false_field\":0,\"empty_struct_field\":{},\"byte_list\":[-127,-1,0,1,127],\"i16_list\":[-1,0,1,32767],\"i32_list\":[-1,0,255,65535,16777215,2147483647],\"i64_list\":[-1,0,255,65535,16777215,4294967295,1099511627775,281474976710655,72057594037927935,9223372036854775807],\"double_list\":[0.1,0.2,0.3],\"string_list\":[\"first\",\"second\",\"third\"],\"boolean_list\":[1,1,1,0,0,0],\"struct_list\":[{},{}],\"i32_set\":[1,2,3],\"boolean_set\":[0,1],\"struct_set\":[{}],\"byte_byte_map\":{\"1\":2},\"boolean_byte_map\":{\"0\":0,\"1\":1},\"byte_i16_map\":{\"1\":1,\"2\":-1,\"3\":32767},\"byte_i32_map\":{\"1\":1,\"2\":-1,\"3\":2147483647},\"byte_i64_map\":{\"1\":1,\"2\":-1,\"3\":9223372036854775807},\"byte_double_map\":{\"1\":0.1,\"2\":-0.1,\"3\":1000000.1},\"byte_string_map\":{\"1\":\"\",\"2\":\"blah\",\"3\":\"loooooooooooooong string\"},\"byte_boolean_map\":{\"1\":1,\"2\":0},\"byte_map_map\":{\"0\":{},\"1\":{\"1\":1},\"2\":{\"1\":1,\"2\":2}},\"byte_set_map\":{\"0\":[],\"1\":[1],\"2\":[1,2]},\"byte_list_map\":{\"0\":[],\"1\":[1],\"2\":[1,2]},\"field500\":500,\"field5000\":5000,\"field20000\":20000}", bufToString());
}
public void testThrowsOnCollectionKeys() throws TException {
diff --git a/lib/java/test/org/apache/thrift/server/ServerTestBase.java b/lib/java/test/org/apache/thrift/server/ServerTestBase.java
index 1dee22d..8348cbc 100644
--- a/lib/java/test/org/apache/thrift/server/ServerTestBase.java
+++ b/lib/java/test/org/apache/thrift/server/ServerTestBase.java
@@ -94,9 +94,13 @@
public ByteBuffer testBinary(ByteBuffer thing) {
StringBuilder sb = new StringBuilder(thing.remaining() * 3);
thing.mark();
- while (thing.remaining() > 0) {
+ int limit = 0; // limit output to keep the log size sane
+ while ((thing.remaining() > 0) && (++limit < 1024)) {
sb.append(String.format("%02X ", thing.get()));
}
+ if(thing.remaining() > 0) {
+ sb.append("..."); // indicate we have more date
+ }
System.out.print("testBinary(" + sb.toString() + ")\n");
thing.reset();
return thing;
diff --git a/test/DebugProtoTest.thrift b/test/DebugProtoTest.thrift
index 0959674..de47ea7 100644
--- a/test/DebugProtoTest.thrift
+++ b/test/DebugProtoTest.thrift
@@ -226,6 +226,10 @@
'byte_map_map' : {0 : {}, 1 : {1 : 1}, 2 : {1 : 1, 2 : 2}},
'byte_set_map' : {0 : [], 1 : [1], 2 : [1, 2]},
'byte_list_map' : {0 : [], 1 : [1], 2 : [1, 2]},
+
+ 'field500' : 500,
+ 'field5000' : 5000,
+ 'field20000' : 20000,
}
diff --git a/test/JavaBinaryDefault.thrift b/test/JavaBinaryDefault.thrift
new file mode 100644
index 0000000..5517802
--- /dev/null
+++ b/test/JavaBinaryDefault.thrift
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace java thrift.test
+
+struct StringAndBinary {
+ 1: optional string strval = ""
+ 2: optional binary binval = ""
+}
diff --git a/test/JavaTypes.thrift b/test/JavaTypes.thrift
index 8c733ad..5553340 100644
--- a/test/JavaTypes.thrift
+++ b/test/JavaTypes.thrift
@@ -27,6 +27,10 @@
1: string val
}
+struct Binary {
+ 1: binary val
+}
+
struct Boolean {
1: bool val
}
diff --git a/test/Makefile.am b/test/Makefile.am
index f6b867c..c2fbbd4 100755
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -158,6 +158,7 @@
Include.thrift \
Int64Test.thrift \
JavaBeansTest.thrift \
+ JavaBinaryDefault.thrift \
JavaDeepCopyTest.thrift \
JavaTypes.thrift \
JsDeepConstructorTest.thrift \
diff --git a/test/c_glib/src/thrift_test_handler.c b/test/c_glib/src/thrift_test_handler.c
index 1d8bcb2..f6c759e 100644
--- a/test/c_glib/src/thrift_test_handler.c
+++ b/test/c_glib/src/thrift_test_handler.c
@@ -30,7 +30,7 @@
G_DEFINE_TYPE (ThriftTestHandler,
thrift_test_handler,
- T_TEST_TYPE_THRIFT_TEST_HANDLER);
+ T_TEST_TYPE_THRIFT_TEST_HANDLER)
gboolean
thrift_test_handler_test_void (TTestThriftTestIf *iface,
diff --git a/test/hs/DebugProtoTest_Main.hs b/test/hs/DebugProtoTest_Main.hs
index fb28963..97d4347 100644
--- a/test/hs/DebugProtoTest_Main.hs
+++ b/test/hs/DebugProtoTest_Main.hs
@@ -117,7 +117,11 @@
Types.compactProtoTestStruct_byte_map_map = Map.empty,
Types.compactProtoTestStruct_byte_set_map = Map.empty,
- Types.compactProtoTestStruct_byte_list_map = Map.empty }
+ Types.compactProtoTestStruct_byte_list_map = Map.empty,
+
+ Types.compactProtoTestStruct_field500 = 500,
+ Types.compactProtoTestStruct_field5000 = 5000,
+ Types.compactProtoTestStruct_field20000 = 20000 }
methodWithDefaultArgs _ arg = do
ThriftTestUtils.serverLog $ "Got methodWithDefaultArgs: " ++ show arg