You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@zookeeper.apache.org by "Brent (Jira)" <ji...@apache.org> on 2021/01/27 05:20:00 UTC

[jira] [Created] (ZOOKEEPER-4194) ZooInspector throws NullPointerExceptions to console when node data is null

Brent created ZOOKEEPER-4194:
--------------------------------

             Summary: ZooInspector throws NullPointerExceptions to console when node data is null
                 Key: ZOOKEEPER-4194
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-4194
             Project: ZooKeeper
          Issue Type: Bug
          Components: contrib
    Affects Versions: 3.7.0
            Reporter: Brent


In certain scenarios when investigating empty nodes, ZooInspector encounters NullPointerExceptions such as (from testing an Apache Helix cluster):
{code:java}
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)
{code}
By default, ZooInspector uses org.apache.zookeeper.inspector.encryption.BasicDataEncryptionManager to decrypt node data using this code:
{code:java}
public String decryptData(byte[] encrypted) throws Exception { 
    return new String(encrypted);
}
{code}
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):
{code:java}
public String decryptData(byte[] encrypted) throws Exception { 
    return encrypted != null ? new String(encrypted) : "";
}
{code}
 I can put this on my list of PRs to submit if that seems reasonable.



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