You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Sebastian Gooren (Jira)" <ji...@apache.org> on 2021/07/25 07:07:00 UTC

[jira] [Created] (WICKET-6908) Possible bug / edge case where page is not detached

Sebastian Gooren created WICKET-6908:
----------------------------------------

             Summary: Possible bug / edge case where page is not detached
                 Key: WICKET-6908
                 URL: https://issues.apache.org/jira/browse/WICKET-6908
             Project: Wicket
          Issue Type: Bug
          Components: wicket-core
    Affects Versions: 9.4.0, 9.3.0
            Reporter: Sebastian Gooren
         Attachments: quickstart.zip

Today I spent the better part of my day investigating a bug report regarding a hibernate LazyInitializationException.
Since we use detaching models everywhere and (in general) never see such issues anymore, this one was interesting :-)
 
After much debugging I found out what is happening.
 
We have a page which has a database model + links for prev/next item (in the database).
When the users double-clicks on one of the links, the first click is OK, and the second click throws a StalePageException during request cycle processing.
 
So far, normal.
 
However, stepping through the wicket code, this is what happens:
 
1) Resolve to ListenerRequestHandler, execute it, throws StalePageException
2) exception mapper handles this and we execute a RenderPageRequestHandler, which re-renders the page
3) the request cycle detaches, which delegates in part to RequestHandlerExecutor.detach()
4) The handlers to detach are both handlers from step 1 and 2; During the detach of ListenerRequestHandler, it initializes ListenerLogData, which (in the PageLogData ctor) throws the StalePageException again!
5) The second handler (RenderPageRequestHandler) is not detached, thus all models in the page are not detached
6) The user clicks on a link and boom, the models are all still attached and there we get the LazyInitializationException
 
I think that (a) RequestHandlerExecutor.detach() should ensure all handlers are detached, and (b) that failing to collect LogData should not stop the detaching of a request handler.
 
What do you think?
 
I tried to make the simplest possible Quickstart to demonstrate this.
 
Weird stuff: on the homepage of the quick start, the page is properly detached when a stale link is clicked;
On another (test) page, the page is not properly detached.
 
Steps to reproduce:
 
Run Quickstart
Click on “Test” link on homepage
Observe that the following is logged:
 
Model still attached? false
Page detaching
 
Now click on "Click me (stale link)!”
Now refresh the page (re-render)
 
Observe that the following is logged:
 
Model still attached? true
Page detaching
 
—> So the page was not detached
 
These steps don’t have the same result on the homepage. So my guess is there is some relation to the fact that we are interacting with a stateful, non-mounted page.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)