GitHub user johnboiles opened a pull request: https://github.com/apache/thrift/pull/1461
Golang: fix for (deprecated) New*ClientFactory and New*ClientProtocol functions Latest thrift:master can cause panics when using deprecated `New*ClientFactory` and `New*ClientProtocol` functions. This happens because both the Client and the BaseClient have an instance of a `thrift.TClient`. The deprecated methods initialize the BaseClient's TClient, but other methods use the Client's `TClient`. For example, current thrift master generates structs like this ``` type MyServiceClient struct { c thrift.TClient *MyServiceBaseClient } type MyServiceBaseClient struct { c thrift.TClient } ``` And also a method like this: ``` func NewMyServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *MyServiceClient { return &MyServiceClient{MyServiceBaseClient: NewMyServiceBaseClientFactory(t, f)} } ``` If that method is used, later calls to service methods will panic, since `p.c` is nil (the actual client was stored in `p.BaseMyServiceClient.c`). ``` func (p *MyServiceClient) DoStuff(ctx context.Context, request *DoStuffRequest) (r *DoStuffResponse, err error) { var _args139 DoStuffArgs _args139.Request = request var _result140 DoStuffResult if err = p.c.Call(ctx, "do_stuff", &_args139, &_result140); err != nil { // PANIC ... ``` The fix in this PR merely sets both instances of `TClient`. Though probably a better fix would be to either remove these deprecated methods, or figure out which `TClient` is the correct one to set. I'm not sure which is right, so hoping to get some feedback/input here. You can merge this pull request into a Git repository by running: $ git pull https://github.com/johnboiles/thrift golang-fix-broken-client-factory Alternatively you can review and apply these changes as the patch at: https://github.com/apache/thrift/pull/1461.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1461 ---- commit d0c76c316c67241fc0e5add1e76e6128bf063ac2 Author: John Boiles <johnaboiles@...> Date: 2018-01-08T21:53:43Z Fix New*ClientFactory and New*ClientProtocol methods to prevent panics commit fc87b4ad579e0f7a9f28ffc4a272f362cd2089ec Author: John Boiles <johnaboiles@...> Date: 2018-01-08T22:18:47Z Fix formatting for New*ClientFactory and New*ClientProtocol methods ---- ---