Merge pull request #2191 from zeshuai007/Implements_TConfig

THRIFT-5237 Implement MAX_MESSAGE_SIZE and consolidate limits into a TConfiguration class(JAVA)
diff --git a/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc b/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc
index 2a92183..8cb82c1 100644
--- a/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc
@@ -2371,48 +2371,6 @@
         }
         f_service_ << "return_value, "
                    << "NULL);" << endl;
-
-        // Deallocate (or unref) return_value
-        return_type = get_true_type(return_type);
-        if (return_type->is_base_type()) {
-          t_base_type* base_type = ((t_base_type*)return_type);
-
-          if (base_type->get_base() == t_base_type::TYPE_STRING) {
-            f_service_ << indent() << "if (return_value != NULL)" << endl;
-            indent_up();
-            if (base_type->is_binary()) {
-              f_service_ << indent() << "g_byte_array_unref (return_value);" << endl;
-            } else {
-              f_service_ << indent() << "g_free (return_value);" << endl;
-            }
-            indent_down();
-          }
-        } else if (return_type->is_container()) {
-          f_service_ << indent() << "if (return_value != NULL)" << endl;
-          indent_up();
-
-          if (return_type->is_list()) {
-            t_type* elem_type = ((t_list*)return_type)->get_elem_type();
-
-            f_service_ << indent();
-            if (is_numeric(elem_type)) {
-              f_service_ << "g_array_unref";
-            } else {
-              f_service_ << "g_ptr_array_unref";
-            }
-            f_service_ << " (return_value);" << endl;
-          } else if (return_type->is_map() || return_type->is_set()) {
-            f_service_ << indent() << "g_hash_table_unref (return_value);" << endl;
-          }
-
-          indent_down();
-        } else if (return_type->is_struct()) {
-          f_service_ << indent() << "if (return_value != NULL)" << endl;
-          indent_up();
-          f_service_ << indent() << "g_object_unref (return_value);" << endl;
-          indent_down();
-        }
-
         f_service_ << endl;
       }
       f_service_ << indent() << "result =" << endl;
@@ -2551,6 +2509,47 @@
     }
 
     if (!(*function_iter)->is_oneway()) {
+      if (has_return_value) {
+        // Deallocate (or unref) return_value
+        return_type = get_true_type(return_type);
+        if (return_type->is_base_type()) {
+          t_base_type* base_type = ((t_base_type*)return_type);
+            if (base_type->get_base() == t_base_type::TYPE_STRING) {
+            f_service_ << indent() << "if (return_value != NULL)" << endl;
+            indent_up();
+            if (base_type->is_binary()) {
+              f_service_ << indent() << "g_byte_array_unref (return_value);" << endl;
+            } else {
+              f_service_ << indent() << "g_free (return_value);" << endl;
+            }
+            indent_down();
+          }
+        } else if (return_type->is_container()) {
+          f_service_ << indent() << "if (return_value != NULL)" << endl;
+          indent_up();
+
+          if (return_type->is_list()) {
+            t_type* elem_type = ((t_list*)return_type)->get_elem_type();
+
+            f_service_ << indent();
+            if (is_numeric(elem_type)) {
+              f_service_ << "g_array_unref";
+            } else {
+              f_service_ << "g_ptr_array_unref";
+            }
+            f_service_ << " (return_value);" << endl;
+          } else if (return_type->is_map() || return_type->is_set()) {
+            f_service_ << indent() << "g_hash_table_unref (return_value);" << endl;
+          }
+
+          indent_down();
+        } else if (return_type->is_struct()) {
+          f_service_ << indent() << "if (return_value != NULL)" << endl;
+          indent_up();
+          f_service_ << indent() << "g_object_unref (return_value);" << endl;
+          indent_down();
+        }
+      }
       f_service_ << indent() << "g_object_unref (result_struct);" << endl << endl << indent()
                  << "if (result == TRUE)" << endl;
       indent_up();
diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.h b/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.h
index c91f52f..912929e 100644
--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.h
+++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.h
@@ -68,6 +68,32 @@
 /* used by THRIFT_TYPE_SOCKET */
 GType thrift_socket_get_type (void);
 
+/**
+ * Check if the socket is open and ready to send and receive
+ * @param transport
+ * @return true if open
+ */
+gboolean
+thrift_socket_is_open (ThriftTransport *transport);
+
+/**
+ * Open connection if required and set the socket to be ready to send and receive
+ * @param transport
+ * @param error
+ * @return true if operation was correct
+ */
+gboolean
+thrift_socket_open (ThriftTransport *transport, GError **error);
+
+/**
+ * Close connection if required
+ * @param transport
+ * @param error
+ * @return true if operation was correct
+ */
+gboolean
+thrift_socket_close (ThriftTransport *transport, GError **error);
+
 G_END_DECLS
 
 #endif
diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_ssl_socket.h b/lib/c_glib/src/thrift/c_glib/transport/thrift_ssl_socket.h
index 0ca465a..dd07c63 100644
--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_ssl_socket.h
+++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_ssl_socket.h
@@ -188,6 +188,15 @@
 gboolean
 thrift_ssl_socket_open (ThriftTransport *transport, GError **error);
 
+/**
+ * Close connection if required
+ * @param transport
+ * @param error
+ * @return true if operation was correct
+ */
+gboolean
+thrift_ssl_socket_close (ThriftTransport *transport, GError **error);
+
 
 /**
  * @brief Initialization function
diff --git a/test/known_failures_Linux.json b/test/known_failures_Linux.json
index 10afb81..ff227c4 100644
--- a/test/known_failures_Linux.json
+++ b/test/known_failures_Linux.json
@@ -517,18 +517,18 @@
   "hs-php_binary-accel_framed-ip",
   "hs-php_json_buffered-ip",
   "hs-php_json_framed-ip",
-  "java-erl-binary-buffered-ip-ssl",
-  "java-erl-binary-fastframed-framed-ip-ssl",
-  "java-erl-binary-framed-ip-ssl",
-  "java-erl-compact-buffered-ip-ssl",
-  "java-erl-compact-fastframed-framed-ip-ssl",
-  "java-erl-compact-framed-ip-ssl",
-  "java-erl-multi-binary-buffered-ip-ssl",
-  "java-erl-multi-binary-fastframed-framed-ip-ssl",
-  "java-erl-multi-binary-framed-ip-ssl",
-  "java-erl-multic-compact-buffered-ip-ssl",
-  "java-erl-multic-compact-fastframed-framed-ip-ssl",
-  "java-erl-multic-compact-framed-ip-ssl",
+  "java-erl-binary_buffered-ip-ssl",
+  "java-erl-binary_fastframed-framed-ip-ssl",
+  "java-erl-binary_framed-ip-ssl",
+  "java-erl-compact_buffered-ip-ssl",
+  "java-erl-compact_fastframed-framed-ip-ssl",
+  "java-erl-compact_framed-ip-ssl",
+  "java-erl-multi-binary_buffered-ip-ssl",
+  "java-erl-multi-binary_fastframed-framed-ip-ssl",
+  "java-erl-multi-binary_framed-ip-ssl",
+  "java-erl-multic-compact_buffered-ip-ssl",
+  "java-erl-multic-compact_fastframed-framed-ip-ssl",
+  "java-erl-multic-compact_framed-ip-ssl",
   "java-netstd_binary_buffered-ip",
   "java-netstd_binary_buffered-ip-ssl",
   "java-netstd_binary_fastframed-framed-ip",