Tapestry 5
  1. Tapestry 5
  2. TAP5-640

DOM manipulation during rendering can NPE

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.1.0.2
    • Fix Version/s: 5.1.0.4
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      We have a number of utilities that do DOM manipulation while the page is rendering. This is often a lot easier than doing it after render and results in more concise code. An example is if you have a list of elements:

      <ul>
      <li>foo</li>
      <li></li>
      <li></li>
      </ul>

      After each LI renders, do something like this:

      if (element.getChildren().isEmpty())
      element.remove();

      It will work for the first empty LI and throw a NPE on the second empty LI because the container inside the element is null (which is odd since it just rendered into a container). But if you wait till after the LIs have all rendered you can loop back and do this safely. However, it's much less readable code and is a real bummer.

        Activity

        Hide
        Howard M. Lewis Ship added a comment -

        Ok, wrote tests, found actual bug in the code that manages the linked list.

        Show
        Howard M. Lewis Ship added a comment - Ok, wrote tests, found actual bug in the code that manages the linked list.
        Hide
        Howard M. Lewis Ship added a comment -

        I'm about to put together a test for this; the only case I can see where this would happen is if you did element.remove() before calling writer.end(). Is that the case? If so ... fix it!

        Show
        Howard M. Lewis Ship added a comment - I'm about to put together a test for this; the only case I can see where this would happen is if you did element.remove() before calling writer.end(). Is that the case? If so ... fix it!
        Hide
        Howard M. Lewis Ship added a comment -

        Obviously, this is related to the work to "de-collection" Element. The changes really shouldn't have been visible to the outside world. A real working test would help a lot in terms of tracking down what's happening.

        Show
        Howard M. Lewis Ship added a comment - Obviously, this is related to the work to "de-collection" Element. The changes really shouldn't have been visible to the outside world. A real working test would help a lot in terms of tracking down what's happening.

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Dan Adams
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development