I typo got me to a stack overflow. Instead of extending WebPage, I extended
Page directly and when wicket tried to render the page it threw a
StackOverflowError caused by the following code:

public class ClockPage extends Page{ //Typo, should be *extends WebPage*

}

Page extends MarkupContainer

public class MarkupContainer ...

public String getMarkupType()
    {
        return getPage().getMarkupType();
    }
...
}

Get page is inherited from Component:

public abstract class Component ...
...
public final Page getPage()
    {
        // Search for nearest Page
        final Page page = findPage();

        // If no Page was found
        if (page == null)
        {
            // Give up with a nice exception
            throw new IllegalStateException("No Page found for component " +
this);
        }

        return page;
    }
...
}

The problem is that getPage() returns an instance to ClockPage, which then
calls getMarkupType() on itself which in turn does a getPage(), returning
the ClockPage instance again, and then it calls getMarkupType() which
call.......... stack overflow.

Is this an unforseen, minor bug? Could it be changed to avoid such a
situation and throw a more user friendly exception so we know we shouldn't
extend Page directly?

Just asking out of curiosity.

Regards,
Daniel Freitas

Reply via email to