Skip to content

Commit

Permalink
fix deregister data race: use atomic oprate
Browse files Browse the repository at this point in the history
  • Loading branch information
binbin0325 authored and undom committed Feb 1, 2021
1 parent 91c7002 commit 7e41051
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion clients/config_client/config_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func Test_SearchConfig(t *testing.T) {
})
assert.Nil(t, err)
assert.NotEmpty(t, configPage)
assert.NotEmpty(t, configPage.PageItems)
assert.True(t, len(configPage.PageItems) == 0)
}

func Test_GetConfigWithErrorResponse_401(t *testing.T) {
Expand Down
7 changes: 2 additions & 5 deletions clients/naming_client/naming_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,8 @@ func (sc *NamingClient) SelectAllInstances(param vo.SelectAllInstancesParam) ([]
param.GroupName = constant.DEFAULT_GROUP
}
service, err := sc.hostReactor.GetServiceInfo(util.GetGroupName(param.ServiceName, param.GroupName), strings.Join(param.Clusters, ","))
if err != nil {
return nil, err
}
if len(service.Hosts) <= 0 {
return []model.Instance{}, errors.New("instance list is empty!")
if err != nil || service.Hosts == nil || len(service.Hosts) == 0 {
return []model.Instance{}, err
}
return service.Hosts, err
}
Expand Down

0 comments on commit 7e41051

Please sign in to comment.