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

Potential NPE in ZKDatabase#calculateTxnLogSizeLimit

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.6.0
    • Fix Version/s: 3.5.4, 3.6.0
    • Component/s: None
    • Labels:
      None

      Description

      I have found a potential NPE in ZKDatabase#calculateTxnLogSizeLimit:

       

      //ZKDatabase
      public long calculateTxnLogSizeLimit() {
      long snapSize = 0;
      try {
      snapSize = snapLog.findMostRecentSnapshot().length();
      } catch (IOException e) {
      LOG.error("Unable to get size of most recent snapshot");
      }
      return (long) (snapSize * snapshotSizeFactor);
      }
      

       in FileTxnSnapLog#findMostRecentSnapshot(), it will return the result of  FileSnap#findMostRecentSnapshot:

      // called by FileTxnSnapLog#findMostRecentSnapshot()
      public File findMostRecentSnapshot() throws IOException {
      List<File> files = findNValidSnapshots(1);
      if (files.size() == 0) {
      return null;
      }
      return files.get(0);
      }
      

      So it will return null when the files sizes is 0, but ZKDatabase#calculateTxnLogSizeLimit has no null checker

       

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                eribeiro Edward Ribeiro
                Reporter:
                xiaoheipangzi lujie
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: