While trying to understand what causes StalePageExceptions (using Wicket 1.5.4), I discovered a strange situation that can occur when DefaultExceptionMapper handles a StalePageException. I decided to ping the mailing list before creating a JIRA issue in case I'm misunderstanding intended behavior.
Consider this scenario: 1) A user logs in and loads a few different pages, eventually landing on Page A. At this point, Page A's version is "5", e.g. /some/path/pageA?5 2) The user opens a new tab and loads Page B 3) The user logs out (or their session times out) while on Page B 4) The user logs back in and interacts with Page B, performing page-level actions that increase the render count of the page, until Page B's version is "5." At this point, a link listener url on Page B looks something like /some/path/pageB?5-3.ILinkListener-someLink 5) The user switches back to their old Page A tab 6) The user clicks an action link (with a listener url like /some/path/pageA?5-1.ILinkListener-someLink) on Page A 7) Wicket throws a StalePageException because the page with version "5" has a render count of 3, not 1 8) At this point, the strange thing occurs: instead of rendering a new version of Page A, Wicket renders Page B. Thus, even though the user attempted to do something on Page A, they are now looking at Page B. Digging into the code, it seems this is due to the implementation of PageProvider.getStoredPage(int pageId). Notably, the javadoc for the method states, "If pageClass is specified then compares it against the stored instance class and returns the found instance only if they match." In the example, pageClass would be PageA.class, but storedPageInstance.getClass() would return PageB.class (the page with id=5 in the newest session). However, even though pageClass and storedPageInstance.getClass() aren't equal, the method still returns storedPageInstance. In this case, shouldn't getStoredPage() should return null, prompting a fresh instantiation of PageA.class? That way, when the user clicks the stale link on Page A, they'll get a fresh rendering of Page A. Thanks for your help! -Allen
