[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-4002?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated ZOOKEEPER-4002:
--------------------------------------
    Labels: pull-request-available  (was: )

> ZKAuditProvider throw NullPointerException if 'AUDIT_ENABLE' is false
> ---------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-4002
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-4002
>             Project: ZooKeeper
>          Issue Type: Bug
>            Reporter: zengchao
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> When other place call ZKAuditProvider.log(...) ,it will  throw a 
> NullPointerException  if 'AUDIT_ENABLE' is false. if 'AUDIT_ENABLE' is false, 
> the static block have not instance 'auditLogger',so when we call log(...),we 
> need to check if 'AUDIT_ENABLE' is true
>  
> {code:java}
> static {
>     auditEnabled = Boolean.getBoolean(AUDIT_ENABLE);
>     if (auditEnabled) {
>         //initialise only when audit logging is enabled
>         auditLogger = getAuditLogger();
>         LOG.info("ZooKeeper audit is enabled.");
>     } else {
>         LOG.info("ZooKeeper audit is disabled.");
>     }
> }
> public static void log(String user, String operation, String znode, String 
> acl,
>                        String createMode, String session, String ip, Result 
> result) {
>     auditLogger.logAuditEvent(createLogEvent(user, operation, znode, acl, 
> createMode, session, ip, result));
> }
> {code}
> Change to:
> {code:java}
> public static void log(String user, String operation, String znode, String 
> acl,
>                        String createMode, String session, String ip, Result 
> result) {
>     if (isAuditEnabled()) {
>         auditLogger.logAuditEvent(createLogEvent(user, operation, znode, acl, 
> createMode, session, ip, result));
>     }
> }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to