Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2671

Enclosure causes Nullpointer exception

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 1.4.5
    • 1.4.6
    • wicket
    • None

    Description

      There is a bug in DirectChildTagIterator which causes a Nullpointer exception with the following stack trace:

      Caused by: java.lang.NullPointerException
      at org.apache.wicket.markup.html.internal.DirectChildTagIterator.findNext(DirectChildTagIterator.java:115)
      at org.apache.wicket.markup.html.internal.DirectChildTagIterator.next(DirectChildTagIterator.java:85)
      at org.apache.wicket.markup.html.internal.Enclosure.ensureAllChildrenPresent(Enclosure.java:236)
      at org.apache.wicket.markup.html.internal.Enclosure.onComponentTagBody(Enclosure.java:169)
      at org.apache.wicket.Component.renderComponent(Component.java:2619)
      ... 106 more

      The problem is in this code fragment:

      while (markupStream.hasMore())
      {
      final MarkupElement cursor = markupStream.next();
      if (cursor.closes(parent))

      markupStream.hasMore() checks if the currentindex is available to retrieve, while markupStream.next() doesn't retrieve the currentindex, but tries to retrieve the currentindex + 1 element. The right function to get the current element is markupStream.get().

      To fix this, it should be like this:

      while (markupStream.hasMore())
      {
      final MarkupElement cursor = markupStream.get();
      markupStream.next();
      if (cursor.closes(parent))

      The best fix is imo to make next() in MarkupStream a void method, which will prevent this in the future.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            jdonnerstag Juegen Donnerstag
            sv3n Sven Rienstra
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment