Closed thedevop closed 9 months ago
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
server.go | 6 | 99.14% | ||
<!-- | Total: | 6 | --> |
Totals | |
---|---|
Change from base Build 7495506564: | -0.1% |
Covered Lines: | 5545 |
Relevant Lines: | 5621 |
This is a very nice fix, thank you @thedevop. I really like what you've done here.
… to avoid data race
In tests, Capabilities maybe altered. However, DefaultServerCapabilities is a single global instance, where it maybe embedded in running server instances. So when value is altered, tests may fail with data race issue.
Here is an example: In TestServerProcessSubscribeACLCheckDenyObscure: https://github.com/mochi-mqtt/server/blob/65c78534dcb5861dc8ea2163ac58ce603b6e9881/server_test.go#L2790-L2794 and TestServerClearExpiredRetained https://github.com/mochi-mqtt/server/blob/65c78534dcb5861dc8ea2163ac58ce603b6e9881/server_test.go#L3328 are seemingly different tests, but they cause interferences and resulted in data race issue.
This surfaced in the failed test for PR #359.
Note, this is mostly a test issue, as normally one would (should) not alter server capabilities once server started serving.
This may also be the cause for data race issue seen in #200.