-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Improve AuditEventRepository #5854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f870d95 to
c592fb9
Compare
* pr/5854: Polish "Improve AuditEventRepository" Improve AuditEventRepository
Update AuditEventRepository to restore support for `null` arguments and explicitly Javadoc their meaning. See gh-5854
|
Looking at these changes a little more, I'm worried that we're going to break back compatibility if we drop support for calling |
|
3ba2b24 lost all of the synchronization improvements. It would be nice to keep those. |
|
Sorry about that Andy. I just realized the mistake I've made 😶 |
|
I'm going to take care of the synchronisation changes in #6261 |
|
Thanks for merging this! 👍 |
I've recently had some requirements on reporting/handling audit events (which included retrieving the latest events on the system, retrieving events of a specific type for a given user), so it seemed fit to consider the expansion of
AuditEventRepository.Investigating the default implementation (
InMemoryAuditEventRepository) the following things didn't sit well with me:InMemoryAuditEventRepository#find(String, Date)allowsnullprincipal to be used as wildcard for finding events for all users (which is even more confusing considering the fact thatAuditEventconstructor allowsnullprincipal, but that's another story) rather than using separatefindoperationInMemoryAuditEventRepository#addoperation allows passingnullevents, which effectively breaks the aforementionedfindoperation since it relies onnullvalues to indicate the end of its internal circular bufferThis PR adds the following changes to improve the situation:
AuditEventRepositoryfor retrieving events without filtering by principalAuditEventRepositoryfor retrieving events filtered by principal and type of eventInMemoryAuditEventRepository#addinput to preventnullsAuditEventto preventnullprincipalsAuditEventtest coverageFurther improvements to consider:
AuditEventRepositoryfinders to describe use case (this could include deprecating currentfind)removeInMemoryAuditEventRepository#setCapacityand enforce setting capacity only via constructor (note that usingsetCapacitydrops the current buffer if used in runtime)use object instead of method synchronization inInMemoryAuditEventRepositoryAuthorizationAuditListener:50)Thoughts?