You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Sven Rienstra (JIRA)" <ji...@apache.org> on 2010/01/13 16:03:54 UTC

[jira] Updated: (WICKET-2671) Enclosure causes Nullpointer exception

     [ https://issues.apache.org/jira/browse/WICKET-2671?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sven Rienstra updated WICKET-2671:
----------------------------------

    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.

  was:
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, i should be 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, it will prevent this in the future.


> Enclosure causes Nullpointer exception
> --------------------------------------
>
>                 Key: WICKET-2671
>                 URL: https://issues.apache.org/jira/browse/WICKET-2671
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4.5
>            Reporter: Sven Rienstra
>            Priority: Critical
>
> 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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.