Tapestry
  1. Tapestry
  2. TAPESTRY-1177

ForBean can cause NullPointerException when rendered without a template

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 4.1.1
    • Fix Version/s: 4.1.1
    • Component/s: Framework
    • Labels:
      None

      Description

      Create a component which doesn't implement ITemplateComponent. In the component specification, declare a For component, but don't bind its optional "element" parameter. Call the For component's render() method.

      Stacktrace is:

      java.lang.NullPointerException
      Stack Trace:

      • org.apache.tapestry.markup.MarkupWriterImpl.end(MarkupWriterImpl.java:261)
      • org.apache.tapestry.components.ForBean.renderComponent(ForBean.java:183)
      • ...

      The problem is caused by line 140 of ForBean.java:

      String element = HiveMind.isNonBlank(getElement()) ? getElement() : getTemplateTagName();

      Because no element binding was specified, and there's no template, this returns null. The markup writer pushes the null value when begin(null) is called, then barfs when it is popped in end().

      Fix is to not call loopWriter.begin()/end() when element is null.

        Activity

        Phil McCarthy created issue -
        Phil McCarthy made changes -
        Field Original Value New Value
        Attachment ForBean.java.tapestry-1177.patch [ 12346750 ]
        Jesse Kuhnert made changes -
        Fix Version/s 4.1.1 [ 12312021 ]
        Assignee Jesse Kuhnert [ jkuhnert ]
        Jesse Kuhnert made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Mark Thomas made changes -
        Workflow jira [ 12391889 ] Default workflow, editable Closed status [ 12567981 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12567981 ] jira [ 12590012 ]

          People

          • Assignee:
            Jesse Kuhnert
            Reporter:
            Phil McCarthy
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development