You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2018/01/11 02:17:46 UTC
thrift git commit: THRIFT-4447: Fix panic on p.c.Call when using
legacy initializers Client: go
Repository: thrift
Updated Branches:
refs/heads/master d066fa850 -> 080e43ee8
THRIFT-4447: Fix panic on p.c.Call when using legacy initializers
Client: go
This closes #1461
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/080e43ee
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/080e43ee
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/080e43ee
Branch: refs/heads/master
Commit: 080e43ee8e279753c919e08d3aab62a8c5ed4b99
Parents: d066fa8
Author: John Boiles <jo...@gmail.com>
Authored: Mon Jan 8 13:53:43 2018 -0800
Committer: James E. King, III <jk...@apache.org>
Committed: Wed Jan 10 21:17:19 2018 -0500
----------------------------------------------------------------------
.../cpp/src/thrift/generate/t_go_generator.cc | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/080e43ee/compiler/cpp/src/thrift/generate/t_go_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc
index 6cce32b..7727118 100644
--- a/compiler/cpp/src/thrift/generate/t_go_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc
@@ -1878,16 +1878,16 @@ void t_go_generator::generate_service_client(t_service* tservice) {
f_types_ << indent() << "type " << serviceName << "Client struct {" << endl;
indent_up();
- f_types_ << indent() << "c thrift.TClient" << endl;
if (!extends_client.empty()) {
f_types_ << indent() << "*" << extends_client << endl;
+ } else {
+ f_types_ << indent() << "c thrift.TClient" << endl;
}
indent_down();
f_types_ << indent() << "}" << endl << endl;
// Legacy constructor function
- f_types_ << indent() << "// Deprecated: Use New" << serviceName << " instead" << endl;
f_types_ << indent() << "func New" << serviceName
<< "ClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *" << serviceName
<< "Client {" << endl;
@@ -1907,7 +1907,6 @@ void t_go_generator::generate_service_client(t_service* tservice) {
indent_down();
f_types_ << indent() << "}" << endl << endl;
// Legacy constructor function with custom input & output protocols
- f_types_ << indent() << "// Deprecated: Use New" << serviceName << " instead" << endl;
f_types_
<< indent() << "func New" << serviceName
<< "ClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *"
@@ -1936,9 +1935,10 @@ void t_go_generator::generate_service_client(t_service* tservice) {
f_types_ << indent() << "return &" << serviceName << "Client{" << endl;
indent_up();
- f_types_ << indent() << "c: c," << endl;
if (!extends.empty()) {
f_types_ << indent() << extends_field << ": " << extends_client_new << "(c)," << endl;
+ } else {
+ f_types_ << indent() << "c: c," << endl;
}
indent_down();
f_types_ << indent() << "}" << endl;
@@ -1946,6 +1946,14 @@ void t_go_generator::generate_service_client(t_service* tservice) {
indent_down();
f_types_ << indent() << "}" << endl << endl;
+ if (extends.empty()) {
+ f_types_ << indent() << "func (p *" << serviceName << "Client) Client_() thrift.TClient {" << endl;
+ indent_up();
+ f_types_ << indent() << "return p.c" << endl;
+ indent_down();
+ f_types_ << indent() << "}" << endl;
+ }
+
// Generate client method implementations
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::const_iterator f_iter;
@@ -1975,7 +1983,7 @@ void t_go_generator::generate_service_client(t_service* tservice) {
std::string resultName = tmp("_result");
std::string resultType = publicize(method + "_result", true);
f_types_ << indent() << "var " << resultName << " " << resultType << endl;
- f_types_ << indent() << "if err = p.c.Call(ctx, \""
+ f_types_ << indent() << "if err = p.Client_().Call(ctx, \""
<< method << "\", &" << argsName << ", &" << resultName << "); err != nil {" << endl;
indent_up();
@@ -2016,7 +2024,7 @@ void t_go_generator::generate_service_client(t_service* tservice) {
}
} else {
// TODO: would be nice to not to duplicate the call generation
- f_types_ << indent() << "if err := p.c.Call(ctx, \""
+ f_types_ << indent() << "if err := p.Client_().Call(ctx, \""
<< method << "\", &"<< argsName << ", nil); err != nil {" << endl;
indent_up();