0xmyst3ry opened a new pull request, #3828: URL: https://github.com/apache/dubbo-go/pull/3828
### Description Part of #3614 (item 4). Addresses #3819. - `apolloListener`: guard the listener map with an `RWMutex`, and dispatch `OnNewestChange` on a snapshot so listener callbacks never run under the lock. - `TestListener`: guard the mock config response and the test listener's `count`/`event`, update them before signalling completion, and ignore extra events so the `WaitGroup` can't go negative. - Add `TestApolloListenerConcurrent` (add/remove/dispatch/`IsEmpty` from several goroutines). `go test -race -count=1 ./config_center/apollo -run '^TestListener$'` passed 10/10 runs on macOS (Go 1.27.1); on the unmodified code it reported the races. `TestApolloListenerConcurrent` reports data races when the lock is removed. I left `TestListener` in `RACE_SKIP_TESTS`: when the whole package runs under `-race`, it still fails because of a race inside agollo itself (`internalClient.SyncAndUpdate` writes a field that its background `Sync` goroutine reads, triggered by other tests' clients). That's outside this repo, so removing it from the skip list isn't safe yet. ### Checklist - [x] I confirm the target branch is `develop` - [ ] I have run `make fmt` to format my code (ran `gofmt` and `go vet` on the package only) - [ ] I have run `make test` to run local tests (ran `go test -race` on `./config_center/apollo` only) - [x] I have added tests that prove my fix is effective or that my feature works -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
