Wicket
  1. Wicket
  2. WICKET-1765

Extending from org.apache.wicket.Page causes StackOverflowError

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.3.4
    • Fix Version/s: 1.3.5, 1.4-RC1
    • Component/s: wicket
    • Labels:
      None
    • Environment:
      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.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Igor Vaynberg
            Reporter:
            Daniel Freitas
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development