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

Avoid NPE in RateLogger#rateLimitLog

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.8.0, 3.7.1
    • None

    Description

      The newMsg may cause NPE

      /**
       * In addition to the message, it also takes a value.
       */
      public void rateLimitLog(String newMsg, String value) {
          long now = Time.currentElapsedTime();
          if (newMsg.equals(msg)) {
              ++count;
              this.value = value;
              if (now - timestamp >= LOG_INTERVAL) {
                  flush();
                  msg = newMsg;
                  timestamp = now;
                  this.value = value;
              }
          } else {
              flush();
              msg = newMsg;
              this.value = value;
              timestamp = now;
              LOG.warn("Message:{} Value:{}", msg, value);
          }
      }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ruanwenjun Wenjun Ruan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

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