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.