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

Component.getDefaultModelObject() wraps in RuntimeException instead of WicketRuntimeException

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 7.9.0
    • 7.10.0, 8.0.0-M9
    • wicket
    • None

    Description

      If a model throws an exception when wicket tries to get the model value during rendering using Component.getDefaultModelObject() the original exception will be wrapped in a vanilla RuntimeException. This will then be wrapped again in a WicketRuntimeException. Perhaps there is a reason for this behaviour that I'm not aware of, or perhaps it's just accidental? I would expect the getDefaultModelObject() to wrap directly in a WicketRuntimeException, which will propagate the wicket stack properly without further wrapping.

      My use case is a SessionTimeoutException (originating from a timed out session to a third system) that depending on which path wicket has travelled when the exception is thrown, it is sometimes wrapped directly in a WicketRuntimeException and sometimes wrapped in a RuntimeException wrapped in a WicketRuntimeException. This can be handled by the top level exception handler of course, but requires more complexity and may offer a few runtime WTFs...

      Changing Component.getDefaultModelObject() to throw a WicketRuntimeException should be fairly safe since it is a RuntimeException and it will avoid the redundant wrapping.

      Unit test quickstart attached.

      Last: Thank you for awesomeness!

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            mgrigorov Martin Tzvetanov Grigorov
            perhuss Per Huss
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment