Skip to content

Commit

Permalink
Fix history client NPE for invalid shardID (#2679)
Browse files Browse the repository at this point in the history
  • Loading branch information
yycptt committed Mar 30, 2022
1 parent ccba09b commit b440f92
Showing 1 changed file with 19 additions and 27 deletions.
46 changes: 19 additions & 27 deletions client/history/client.go
Expand Up @@ -186,15 +186,13 @@ func (c *clientImpl) DescribeHistoryHost(
func (c *clientImpl) RemoveTask(
ctx context.Context,
request *historyservice.RemoveTaskRequest,
opts ...grpc.CallOption) (*historyservice.RemoveTaskResponse, error) {
var err error
var client historyservice.HistoryServiceClient
if request.GetShardId() != 0 {
client, err = c.getClientForShardID(request.GetShardId())
if err != nil {
return nil, err
}
opts ...grpc.CallOption,
) (*historyservice.RemoveTaskResponse, error) {
client, err := c.getClientForShardID(request.GetShardId())
if err != nil {
return nil, err
}

var response *historyservice.RemoveTaskResponse
op := func(ctx context.Context, client historyservice.HistoryServiceClient) error {
var err error
Expand All @@ -214,16 +212,13 @@ func (c *clientImpl) RemoveTask(
func (c *clientImpl) CloseShard(
ctx context.Context,
request *historyservice.CloseShardRequest,
opts ...grpc.CallOption) (*historyservice.CloseShardResponse, error) {

var err error
var client historyservice.HistoryServiceClient
if request.ShardId != 0 {
client, err = c.getClientForShardID(request.GetShardId())
if err != nil {
return nil, err
}
opts ...grpc.CallOption,
) (*historyservice.CloseShardResponse, error) {
client, err := c.getClientForShardID(request.GetShardId())
if err != nil {
return nil, err
}

var response *historyservice.CloseShardResponse
op := func(ctx context.Context, client historyservice.HistoryServiceClient) error {
var err error
Expand All @@ -243,16 +238,13 @@ func (c *clientImpl) CloseShard(
func (c *clientImpl) GetShard(
ctx context.Context,
request *historyservice.GetShardRequest,
opts ...grpc.CallOption) (*historyservice.GetShardResponse, error) {

var err error
var client historyservice.HistoryServiceClient
if request.ShardId != 0 {
client, err = c.getClientForShardID(request.GetShardId())
if err != nil {
return nil, err
}
opts ...grpc.CallOption,
) (*historyservice.GetShardResponse, error) {
client, err := c.getClientForShardID(request.GetShardId())
if err != nil {
return nil, err
}

var response *historyservice.GetShardResponse
op := func(ctx context.Context, client historyservice.HistoryServiceClient) error {
var err error
Expand Down Expand Up @@ -830,7 +822,7 @@ func (c *clientImpl) SyncShardStatus(
opts ...grpc.CallOption) (*historyservice.SyncShardStatusResponse, error) {

// we do not have a workflow ID here, instead, we have something even better
client, err := c.getClientForShardID(int32(request.GetShardId()))
client, err := c.getClientForShardID(request.GetShardId())
if err != nil {
return nil, err
}
Expand Down

0 comments on commit b440f92

Please sign in to comment.