Skip to content

Commit

Permalink
Don't ignore error in InitThriftClient (#16)
Browse files Browse the repository at this point in the history
`thrift.NewTHttpClientWithOptions` may return an error, in which case
`tTrans` is `nil`, which causes the next line to panic with the message
`interface conversion: thrift.TTransport is nil, not
*thrift.THttpClient` on the next line.

Signed-off-by: Eric Bannatyne <[email protected]>
  • Loading branch information
aldld authored Dec 1, 2022
1 parent 5883857 commit 46f7675
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ func InitThriftClient(cfg *config.Config) (*ThriftServiceClient, error) {
Timeout: cfg.ClientTimeout,
}
tTrans, err = thrift.NewTHttpClientWithOptions(endpoint, thrift.THttpClientOptions{Client: httpclient})
if err != nil {
return nil, err
}

httpTransport := tTrans.(*thrift.THttpClient)
userAgent := fmt.Sprintf("%s/%s", cfg.DriverName, cfg.DriverVersion)
if cfg.UserAgentEntry != "" {
Expand Down

0 comments on commit 46f7675

Please sign in to comment.