zhan7236 opened a new pull request, #16838:
URL: https://github.com/apache/iotdb/pull/16838

   ## Description
   
   This PR fixes the issue where the `enable_audit_log` configuration was not 
taking effect, causing audit logs to always remain disabled even when 
explicitly set to `true`.
   
   Fixes: https://github.com/apache/iotdb/issues/16706
   
   ## Root Cause
   
   The audit log configuration values were defined as `static final` fields in 
`AbstractAuditLogger`:
   
   ```java
   protected static final boolean IS_AUDIT_LOG_ENABLED = 
CONFIG.isEnableAuditLog();
   private static final List<AuditLogOperation> AUDITABLE_OPERATION_TYPE = 
CONFIG.getAuditableOperationType();
   private static final PrivilegeLevel AUDITABLE_OPERATION_LEVEL = 
CONFIG.getAuditableOperationLevel();
   private static final String AUDITABLE_OPERATION_RESULT = 
CONFIG.getAuditableOperationResult();
   ```
   
   These `static final` fields are initialized at class loading time, which may 
occur before the configuration file is fully loaded (especially in Docker 
environments where configuration is injected via environment variables). As a 
result, these values always get the default value (`false` for 
`enable_audit_log`).
   
   ## Solution
   
   Changed the `static final` fields to dynamic method calls that read the 
configuration values at runtime:
   
   - `IS_AUDIT_LOG_ENABLED` → `isAuditLogEnabled()` method
   - `AUDITABLE_OPERATION_TYPE` → `getAuditableOperationType()` method
   - `AUDITABLE_OPERATION_LEVEL` → `getAuditableOperationLevel()` method
   - `AUDITABLE_OPERATION_RESULT` → `getAuditableOperationResult()` method
   
   This ensures that the configuration values are read dynamically after the 
configuration file has been properly loaded.
   
   ## Changed Files
   
   - `AbstractAuditLogger.java`
   - `DNAuditLogger.java`
   - `CNAuditLogger.java`
   
   ## Testing
   
   - [x] Code compiles successfully
   - [x] Code style check passed (`mvn spotless:check`)
   
   ## Checklist
   
   - [x] I have read the Contributing Guidelines
   - [x] I have searched for similar issues before creating this PR
   - [x] The code follows the project's coding style


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