Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
5.8.2
Description
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.
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:?]
To the best of my understanding, the fix is straight forward:
--- 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>() {
Attachments
Attachments
Issue Links
- mentioned in
-
Page Loading...