Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-4002

ZKAuditProvider throw NullPointerException if 'AUDIT_ENABLE' is false

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None

      Description

      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

       

      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));
      }
      

      Change to:

      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));
          }
      }
      

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                zengchao zengchao
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 50m
                  50m