[ https://issues.apache.org/jira/browse/TAP5-2745?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ben Weidig resolved TAP5-2745. ------------------------------ Fix Version/s: 5.8.3 Resolution: Fixed > Tree component with empty list of root nodes causes NullPointerException > ------------------------------------------------------------------------ > > Key: TAP5-2745 > URL: https://issues.apache.org/jira/browse/TAP5-2745 > Project: Tapestry 5 > Issue Type: Bug > Components: tapestry-core > Affects Versions: 5.8.2 > Reporter: Robert Hailey > Assignee: Ben Weidig > Priority: Major > Labels: patch > Fix For: 5.8.3 > > Attachments: TAP5-2745-suggested-fix.patch > > > An edge case, perhaps, but it seems as though attempting to create a Tree > component with no root nodes does not produce an empty list, but throws a > null pointer exception. > {noformat} > java.lang.NullPointerException: Cannot invoke > "org.apache.tapestry5.tree.TreeNode.getValue()" because "this.val$node" is > null > at org.apache.tapestry5.corelib.components.Tree$4.render(Tree.java:169) > ~[tapestry-core-5.8.2.jar:?] > at > org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:79) > ~[tapestry-core-5.8.2.jar:?] > at > org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:121) > ~[tapestry-core-5.8.2.jar:?] > {noformat} > To the best of my understanding, the fix is straight forward: > {noformat} > --- > a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Tree.java > +++ > b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Tree.java > @@ -265,7 +265,12 @@ public class Tree > writer.element("ul"); > queue.push(RENDER_CLOSE_TAG); > > - queue.push(toRenderCommand(nodes.first(), true)); > + TreeNode first = nodes.first(); > + > + if (first != null) > + { > + queue.push(toRenderCommand(first, true)); > + } > > nodes.rest().each(new Worker<TreeNode>() > { > {noformat} -- This message was sent by Atlassian Jira (v8.20.10#820010)