cckellogg commented on a change in pull request #581:
URL: https://github.com/apache/pulsar-client-go/pull/581#discussion_r684330780
##########
File path: pulsar/internal/service_name_resolver.go
##########
@@ -63,6 +66,8 @@ func (r *pulsarServiceNameResolver) ResolveHost() (*url.URL,
error) {
if len(r.AddressList) == 1 {
return r.AddressList[0], nil
}
+ r.mutex.Lock()
+ defer r.mutex.Unlock()
Review comment:
We should move
```
r.mutex.Lock()
defer r.mutex.Unlock()
```
To the top since the func `UpdateServiceURL` below can alter the AddressList
##########
File path: pulsar/internal/service_name_resolver.go
##########
@@ -98,8 +106,9 @@ func (r *pulsarServiceNameResolver) UpdateServiceURL(u
*url.URL) error {
r.AddressList = addresses
r.ServiceURL = u
r.ServiceURI = uri
- rand.Seed(time.Now().Unix()) // initialize global pseudo random
generator
- atomic.StoreInt32(&r.CurrentIndex, int32(rand.Intn(len(addresses))))
+ r.mutex.Lock()
Review comment:
We should move the
```
r.mutex.Lock()
defer r.mutex.Unlock()
```
to under `uri, err := NewPulsarServiceURIFromURL(u)`
Since state other piece of state are being changed.
##########
File path: pulsar/internal/service_name_resolver.go
##########
@@ -42,6 +42,12 @@ type pulsarServiceNameResolver struct {
ServiceURL *url.URL
CurrentIndex int32
AddressList []*url.URL
Review comment:
Not sure why all these are public while the struct is private but that
can be corrected in another MR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]