davidsusu/tree-printer

Run example code throws NullPointerException

Closed this issue · 1 comments

    public static void main(String[] args) throws Exception {
        SimpleTreeNode rootNode = new SimpleTreeNode("I'm the root!");
        rootNode.addChild(new SimpleTreeNode("I'm a child..."));
        rootNode.addChild(new SimpleTreeNode("I'm an other child..."));
        new TraditionalTreePrinter().print(new BorderTreeNodeDecorator(rootNode));
    }

Throws:

Exception in thread "main" java.lang.NullPointerException
	at org.apache.doris.common.treeprinter.TraditionalTreePrinter$DefaultAligner.alignChildren(TraditionalTreePrinter.java:266)
	at org.apache.doris.common.treeprinter.TraditionalTreePrinter.print(TraditionalTreePrinter.java:74)
	at org.apache.doris.common.treeprinter.AbstractTreePrinter.print(AbstractTreePrinter.java:28)
	at cmy.MyTest.main(MyTest.java:43)

The package name is changing to org.apache.doris.common.treeprinter because I need to debug the code in my project.

This is because the AbstractTreeNode class missing equals and hashCode method.
I will submit a PR to fix this.

Thank you for your contribution. I will publish it to the maven central soon.