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

Extending from org.apache.wicket.Page causes StackOverflowError

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.3.4
    • 1.3.5, 1.4-RC1
    • wicket
    • None
    • Windows XP, Eclipse Ganymede, Wicket 1.3.4, Embedded Jetty

    Description

      Extending directly from Page, instead of WebPage, causes a StackOverflowError due to a recursive loop.
      The problem could be tracked down to the following code:

      Example code:
      public class ClockPage extends Page

      { // Extends page directly }

      //-----------Page extends MarkupContainer

      public class MarkupContainer ...

      public String getMarkupType()

      { return getPage().getMarkupType(); }

      ...
      }

      //---------getPpage() 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;
      }
      ...
      }

      When extending directly from page, getPage() (inherited from Component) returns an instance to the ClockPage in the example above, which then calls getMarkupType() on itself which will call getPage() again and on an on until a stack overflow occur.

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            daniel.mfreitas Daniel Freitas
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: