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

ZooInspector throws NullPointerExceptions to console when node data is null

VotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      In certain scenarios when investigating empty nodes, ZooInspector encounters NullPointerExceptions such as (from testing an Apache Helix cluster):

      ERROR [SwingWorker-pool-1-thread-3] (ZooInspectorManagerImpl.java:255) - Error occurred getting data for node: /BrentTest/EXTERNALVIEWERROR [SwingWorker-pool-1-thread-3] (ZooInspectorManagerImpl.java:255) - Error occurred getting data for node: /BrentTest/EXTERNALVIEWjava.lang.NullPointerException at java.lang.String.<init>(String.java:566) at org.apache.zookeeper.inspector.encryption.BasicDataEncryptionManager.decryptData(BasicDataEncryptionManager.java:33) at org.apache.zookeeper.inspector.manager.ZooInspectorManagerImpl.getData(ZooInspectorManagerImpl.java:251) at org.apache.zookeeper.inspector.gui.nodeviewer.NodeViewerData$2.doInBackground(NodeViewerData.java:105) at org.apache.zookeeper.inspector.gui.nodeviewer.NodeViewerData$2.doInBackground(NodeViewerData.java:100) at javax.swing.SwingWorker$1.call(SwingWorker.java:295) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at javax.swing.SwingWorker.run(SwingWorker.java:334) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
      

      By default, ZooInspector uses org.apache.zookeeper.inspector.encryption.BasicDataEncryptionManager to decrypt node data using this code:

      public String decryptData(byte[] encrypted) throws Exception { 
          return new String(encrypted);
      }
      

      But "encrypted" can get passed as "null" which causes the issue.  It seems like this is probably a pretty easy fix (this code seems to do it):

      public String decryptData(byte[] encrypted) throws Exception { 
          return encrypted != null ? new String(encrypted) : "";
      }
      

       I can put this on my list of PRs to submit if that seems reasonable.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            brentwritescode Brent
            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 - 40m
                40m

                Slack

                  Issue deployment