R0CKing666 opened a new pull request, #11190:
URL: https://github.com/apache/rocketmq/pull/11190

   ### Which Issue(s) This PR Fixes
   
   - Fixes #11189
   
   ### Brief Description
   
   The admin write path mutates the cached ACL/User objects in place. 
`AuthorizationMetadataManagerImpl.createAcl/updateAcl/deleteAcl` read the 
cached `Acl` via `getAcl` and then call `updatePolicy`/`deletePolicy` on it 
directly; `AuthenticationMetadataManagerImpl.updateUser` calls 
`setPassword/setUserType/setUserStatus` on the cached `User`. Because 
`LocalAuthorizationMetadataProvider.getAcl` and 
`LocalAuthenticationMetadataProvider.getUser` return the very object held by 
the Caffeine cache (no defensive copy), the admin write and the 
authorization/authentication hot path share the same mutable object. Readers 
can therefore observe a half-updated state, and concurrent structural 
modification can throw `ConcurrentModificationException`; if the RocksDB write 
fails, the in-memory cache also diverges from disk.
   
   This change makes the write path copy-on-write: the managers build a deep 
copy of the cached instance, apply the change to the copy, and persist the 
copy. The cached instance is only ever replaced atomically (via cache 
invalidation + reload) after a successful write, so the hot path keeps reading 
the cached reference without any per-request copy cost.
   
   ### How Did You Test This Change?
   
   - Added regression tests verifying that `updateAcl`/`deleteAcl`/`updateUser` 
no longer mutate a previously-read cached instance, while a fresh read still 
reflects the update.
   - Ran the full `rocketmq-auth` test suite: 96 tests, 0 failures, 0 errors.
   - Checkstyle: 0 violations.
   


-- 
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]

Reply via email to