refactor(audit): using atomic type atomic.Uint32#9498
refactor(audit): using atomic type atomic.Uint32#9498cuiweixie wants to merge 1 commit intodgraph-io:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the audit module to use the atomic type atomic.Uint32 instead of manually using atomic package functions with a uint32 variable. This change modernizes the code to use Go's newer atomic types that provide cleaner syntax and better type safety.
- Replaces
uint32variable withatomic.Uint32type - Updates all atomic operations to use the built-in methods
- Simplifies code by removing explicit atomic package function calls
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| audit/audit.go | Changes variable declaration from uint32 to atomic.Uint32 and updates Store/Load operations |
| audit/interceptor.go | Updates all Load operations to use the new atomic type's built-in methods |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if auditEnabled.Load() == 0 { | ||
| return | ||
| } | ||
| auditor.log.Sync() |
There was a problem hiding this comment.
The audit log is being synchronized but auditEnabled is not being reset to 0 after closing. This means the enabled check will continue to pass even after the auditor is closed, potentially causing nil pointer dereferences when trying to use the closed log.
d5c7ee8 to
7a1faf2
Compare
Description
Please explain the changes you made here.
Checklist
CHANGELOG.mdfile describing and linking tothis PR
docs repo staged and linked here
Instructions
syntax, leading with
fix:,feat:,chore:,ci:, etc.link to the bug.
[x]syntax.back and check the box later.
Instructionsline and everything below it, to indicate you have read and arefollowing these instructions. 🙂
Thank you for your contribution to Dgraph!