CodingCaius opened a new pull request, #62: URL: https://github.com/apache/casbin-redis-watcher/pull/62
Closing a watcher currently broadcasts the plain-text payload `Close` on the policy channel, causing other watchers to report JSON parsing errors during normal shutdown. Select on the local close signal alongside incoming Redis messages so an idle receiver can exit without a Redis wake-up message. Keep the existing deferred resource cleanup and stop check before processing a received message, and make repeated `Close()` calls safe with `sync.Once`. The regression tests use an independent Redis subscriber to verify that shutdown publishes no message, the idle subscription and owned clients are released, and a surviving watcher still publishes and receives normal updates. A second test covers concurrent repeated closes. Fixes #61. ### Validation - The new broadcast regression fails on unmodified master with `Close published a non-JSON message: "Close"`. - `go test -mod=readonly -covermode atomic -coverprofile=covprofile ./...` — passed, 78.9% statement coverage. - `go test -mod=readonly -race -run '^TestWatcherClose' -count=10 ./...` — passed. - `golangci-lint run ./...` — 0 issues. - Tested locally with Go 1.26.2 and Redis 7.2 in a loopback-only test container. The patch uses APIs available in the project's Go 1.23 baseline. -- 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]
