Closed BlackBear2003 closed 5 months ago
The changes primarily involve modifying access levels and enhancing functionality related to auditing in the Apollo framework. The scopeManager
method in ApolloAuditTracer
is now protected
instead of public
. Enhancements in ApolloAuditOperatorDefaultSupplier
enable it to fetch the operator from the active audit span. Corresponding tests have been added to validate these behaviors.
File Path | Summary of Changes |
---|---|
.../ApolloAuditTracer.java |
Changed scopeManager method's access modifier from public to protected . |
.../ApolloAuditOperatorDefaultSupplier.java |
Added import for ApolloAuditSpan and modified getOperator method to fetch operator from the active span or return "anonymous". |
.../ApolloAuditOperatorSupplierTest.java |
Added test methods for scenarios with and without an active span. Included necessary imports for testing. |
sequenceDiagram
participant Client
participant ApolloAuditOperatorDefaultSupplier
participant ApolloAuditSpan
participant ApolloAuditTracer
Client->>ApolloAuditOperatorDefaultSupplier: getOperator()
ApolloAuditOperatorDefaultSupplier->>ApolloAuditTracer: scopeManager()
ApolloAuditTracer-->>ApolloAuditOperatorDefaultSupplier: ApolloAuditScopeManager
ApolloAuditOperatorDefaultSupplier->>ApolloAuditSpan: getActiveSpan()
alt Active Span Exists
ApolloAuditSpan-->>ApolloAuditOperatorDefaultSupplier: operator
else No Active Span
ApolloAuditOperatorDefaultSupplier-->>Client: "anonymous"
end
In the code where audits bloom,
Changes sweep away the gloom.
Protected methods, spans in flight,
Operators now in clear sight.
Tests ensure the path is true,
Apollo's audit shines anew. 🌟
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
What's the purpose of this PR
To fix existing NPE bug in audit logging
when there is no active span exists on request thread context, trying to get operator will cause NPE by continuously get().
causing NPE codes
prof by unit test
In some case this bug will appear:
Set
audit.log.enabled=false
in Portal andaudit.log.enabled=true
in AdminService.In this case, no activeSpan would be passed to AdminService, meanwhile AdminService would get operator through active span. And then cause NPE.
Brief changelog
Follow this checklist to help us incorporate your contribution quickly and easily:
mvn clean test
to make sure this pull request doesn't break anything.CHANGES
log.Summary by CodeRabbit
Bug Fixes
Tests