Copilot commented on code in PR #3755:
URL: https://github.com/apache/dubbo-go/pull/3755#discussion_r4219250543
##########
protocol/grpc/active_notify_test.go:
##########
@@ -130,10 +145,13 @@ func TestGrpcHealthWatchEmitsClosingEvent(t *testing.T) {
healthServer.SetServingStatus(serviceKey,
grpc_health_v1.HealthCheckResponse_NOT_SERVING)
require.Eventually(t, func() bool {
- return len(handler.events) == 1
+ return len(handler.eventsSnapshot()) == 1
Review Comment:
In `require.Eventually`, `eventsSnapshot()` is called repeatedly and
allocates/copies the slice each poll. This is test code, but it can still slow
down/flake under `-race`. Consider adding a cheap synchronized accessor (e.g.,
`eventsLen()` under `RLock`), or replace the polling of snapshots with a
signaling mechanism (e.g., send the event into a buffered channel in
`HandleClosingEvent` and wait on it) to avoid repeated allocations and reduce
timing sensitivity.
--
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]